Wednesday, August 10, 2011

Learn JavaScript completely On the Cloud With the JavaScript Koans and Cloud9 IDE

Lately I've been investing a lot of time into learning JavaScript and one of the neatest things I've come across is the JavaScript Koans project.  If you haven't heard of Koans before the basic concept is to learn a programming language through the act completing unit tests in that language.   The most popular implementation of this concept is the Ruby Koans project (http://rubykoans.com/).  Liam McLennan took this concept and ported it over to JavaScript and his implementation can be found over on github (https://github.com/liammclennan/JavaScript-Koans).

When you pair this repository with the Cloud9 IDE you can work on them completely on the cloud without having to download a single piece of code locally.  Cloud9 (http://cloud9ide.com/) is an completely online and very richly featured IDE.  One of the great things about Cloud 9 is that it can access your github repositories and clone them into its environment for you to edit.  Cloud9 also provides you with a interactive console with git installed so you can push the changes back into your repository. The console will even give you intellisence on the git commands as shown to the right!

Assuming you already have a github account the first step is to fork a copy of the JavaScript Koans repository.  Once you have a forked copy of the Koans head over to the Cloud9 website and log into your dashboard.  Your dashboard will have a "Add On Services" section that will allow you to connect Cloud9 with your github account and pull in your public repositories.  One thing I've noticed is that if you've added a new repository since you last connected with github you'll have to connect to github again for Cloud9 to pull in the newly created repository.   Once the repository is pulled into Cloud9 next you'll have to select the project from the github menu and click on the "Clone to Edit" in order to be able to edit the files.

Once your github repository is cloned it will show up as a new project in the Projects area.  First click on the Koans project and click on the "Start Editing" button which will open up the project in a new tab.   Once your koans project is open double click on the "jskoans.htm" file to open it up in the editor.  The editor will detect that this is a HTML file and a "preview" icon will appear in the editor.  Click on this button to run the Koans.  When you do the jskoans.htm file will open in a new tab and run the koans unit tests, which will fail on the first test like so:



Whats important to note here is which file the error occurred on. The Koans are organized by topics, and each topic will have its own JavaScript file with qUnit tests that pertain to that topic.  Find that file that caused the error in the editor and open it.  You'll now see all the qUnit tests for that file.  Below you'll see the code from the first topic which is a brief overview of assertions.


Inside the assertion code there will always be two underscores "__" that denote an area where you are to fill in a value to make the test pass.  As you go through the exersizes save the unit test file and refresh the jskoans.htm preview page and you'll start to fill the page with passed tests.  The test runner will stop at the first failed test it finds. As more and more of the tests pass the page will begin to fill up with passed tests as shown in the image to the right.

Whats great about the koans is that its an open source project so community members can add more tests and actively improve the tests that are there, which are very good right now.  Some of the topics covered are: arrays, reflection, prototypical inheritance, objects, and functions and closures. Going through these you'll get to learn JavaScript the best way, by writing JavaScript.




Monday, August 8, 2011

The ColdFusion Geeks Fantasy Football League Needs Two More Teams!

This is the second year of the ColdFusion Geeks league (http://football.fantasysports.yahoo.com/f1/256516), and I've decided to expand it to 12 teams instead of 10.  I'm looking to fill those two spots with ColdFusion lovers who also love to play fantasy football. The winner is promised everlasting glory and lifelong bragging rights within the community.  

This is a free league all that I ask is you play till the end, even if you are 0 and 12 in week 13.  If you are interested you can send me a message on twitter or use the contact form of this blog.

Monday, August 1, 2011

How I Got Started In ColdFusion

The year was 1997.  Puff Daddy's "I'll Be Missing You" and Hanson's "Mmm Bop" ruled the airwaves and I was a skinny 19 year old stuck in an Architectural Technician program that I had zero passion for.  One day while sitting in the Milwaukee Area Technical College computer lab researching the Empire State Building I inadvertently right clicked on a web page trying to copy some text and noticed this option called "View Source" in the menu.  Being the inquisitive type that I am I decided to click on it to see what it did.  Notepad opened up and with it opened a whole new world to me.

At first I wasn't sure what all of these and
things meant but I was able to quickly develop a hypothesis in my head.  Within minutes I created a geocities account and was busy writing "Ryan's Awesome Car Picture Page" which featured a bunch of pictures of cars I found browsing the net.  Tables with a border size of 10 were a common site on this page.  My mind quickly jumped to the prospect of writing my Empire State Building paper as a website.  Architecture had become fun again, or at least writing a webpage about architecture was.  The page featured a repeating green marble background, white text, and some images of greek-style columns, was littered with markup errors, but was I ever proud of it.  I couldn't believe how much fun I had creating it either.  Grown up I was always interested in computers, but the only thing I had ever done with them was load games off a floppy disk and occasionally browse Prodigy.

I'll never forget the look on my professors face when I handed in my paper that had just one line on it: http://www.geocities.com/.... The very next day he pulled me into his office and told me that one of his former students was starting a company creating websites and that I should get in contact with her.  I'm a huge procrastinator, but this was one opportunity that I immediately jumped on.  The very next day I had an interview scheduled.  Apparently that interview went well because a week later I was busy scanning images out of an Oldsmobile car brochure for a car dealership website.

Fast forward a few months and a few static websites later.  The company I was working for, IDL Solutions, had been maintaining the Wisconsin Lottery website.  This was by far their most important client and they weren't about to let some greenhorn loose on it, however the owners were leaving town on vacation and I was called upon to enter the winning numbers for the lottery that night.  Tony, the companies co-owner and author of the lottery website sat me down and began to walk me through the process of updating numbers.  I immediately noticed that the pages he was showing me all ended in .cfm instead of the .html or .html links I was used to.  When I asked him about it he told me of this magical product by a company called Allaire called ColdFusion.  He continued to tell me how easy it made creating database driven websites and showed me some of the source code behind the lottery website.  I couldn't believe what I was seeing.  Up until this point all I had ever heard of was this language called CGI to create dynamic web pages.  CGI was way above my head at the time so ColdFusion seemed like one of the greatest things ever to me.  

It wasn't long before I had the "Ryan's World Tour" webpage up.  It was basically a very early implementation of a blog.  Every time I'd go out and party I'd write up a short story of the nights shenanigans and post it on the website and allowed my friends to comment on the stories.  I couldn't believe how much fun I was writing this website, I was hooked.   After the semester was over I stopped taking Architecture classes and switched all of my classes to computer classes.  For the next 4 years I worked with exclusively with ColdFusion doing pretty basic stuff: event sign up forms, parsing CSV files, and creating job websites...pretty much the same thing everybody was doing in the late 90's.

It wasn't until 2003 and the Macromedia MAX event in Utah that my eyes were opened to a whole new programming paradigm and I started taking my development seriously.  ColdFusion MX 6 had just come out and a lot of the ColdFusion sessions were on this new construct in the language called ColdFusion Components.  A particular session by Simon Horwith changed the way I looked at writing applications forever.  He showed us how, using CFC's, ColdFusion could be written using an object-oriented approach.  This was the first time I felt like I could become a "legitimate" programmer doing ColdFusion.  From that day on I haven't stopped trying to learn how to craft my applications better.

This is the point where I can say that I REALLY got started working with ColdFusion.  I stopped writing procedural spaghetti code and started to write reusable maintainable code.  I also started challenging myself to learn new things.  The more I learned the more I realized that I didn't know as much as I thought I knew.
To this day, that pattern continues.  Everyday I learn something new which makes me realized exactly how much I don't know.  This is a message that I try to pass on to ColdFusion developers that I talk to that seem to be in a rut.   It's so easy to be satisfied with what you know and keep the status quo.  It's easy to write code the same way you've always written code.  Its easy to follow the developers before you and do exactly what they did. In contrast it's hard to always feel like you have a mountain of things to learn.  It's hard to look at the code you wrote two months ago and want to rewrite every single line because you can't believe you were so stupid back then.

This is also what makes being a programmer so dam fun.  I'm never bored and I love the fact that there's always something new and exciting to learn.  ColdFusion started me down this path and for that I'll always remain a loyal ColdFusion programmer.  Of course I'll continue learn new languages along the way but when the rubber meets the road and I know I have to get a project done, ColdFusion is always the language I'll fall back to because I know it can do the job and do it well.
Fork me on GitHub