Wednesday, May 06, 2015

Red Green–A different Hello World

imageHello World is more or less the ubiquitous first program for most development environments. I hate it. It’s boring. It made a lot of sense in a command line environment but for a more graphical development especially with event driven programming it seems like a dull start.

The purpose of “Hello World” is really just to get students familiar with the development environment. One wants them to create a project, do something simple with it and run the resulting program. It’s about familiarity and early success as much as anything else.

For the last several years, when introducing Visual Basic we’ve been using a program I call Red Green. It consists of a pair of buttons – one labeled “Red” and the other labeled “Green.” Clicking on a button changes the background color of the form to the named color. The code is obviously, and deliberately, simple. A simple assignment statement is all it takes for each button. Once we do the first two buttons as a class I ask the students to copy the buttons and add other colors to the mix.

What I like about it is that I get to explain some basic things like how to maneuver around Visual Studio. They create a project (and I can make sure it is saved on the class’ network drive), they add a few objects and we get an early start talking about object properties. There are assignment statements but nothing more complicated that they have to understand. After this we can start with real programming concepts and move along. But students start with something fun that gives them a little taste of success.

Many students start to explore more options right away though. They load pictures into the buttons for example. Or play with other properties (fonts and foreground colors for example). Students learn that they can in fact learn on their own and that it is ok to do so.  I want them to try things!

3 comments:

Stephen Downes said...

The irony is that you gave us a non-functioning illustration.

Anonymous said...

While teaching this yesterday, I also changed the background colors of the buttons (to further demonstrate the Properties) ... and caused a few OCD moments when I gave the button that said "Green" a red background 8^)

Alfred C Thompson II said...

Well Stephen I can write the Windows application version using a single user written line of code. Although students did it with one line per button. I just don't know how to do that as a web app with so few lines of user written code.