Click here to Skip to main content
15,885,985 members
Articles / All Topics
Technical Blog

The Power of "Hello World"

Rate me:
Please Sign up or sign in to vote.
5.00/5 (5 votes)
21 May 2013CPOL3 min read 6.7K   1
The power of "Hello World".

There are two kinds of things you write, when you write a program:

  1. Things you're absolutely sure about
  2. The rest

Point 1 is things you write 10 times a day. You definitely know how to declare a string variable. You definitely know how to write a for loop. There's a bunch of other things you're firmly sure about. Point 2 is things you don't do every day. Or even things you never did before.

I'm pretty sure, there are only two points. There's no point 1.5 where you "well... sure" - it's always either you're sure or not.

Point 2 is when you feel uncertainty.

The worst thing one can do in this case is get some coffee, turn the brain off and try to do whatever needed. In most cases, it won't work. You write some code, you run your program and see it doesn't do what you expect. You make changes, you rerun it, same story. 10 minutes later you start thinking if it's not your issue, but some other code, you spend 20 minutes more to check it and so on.

There's a trick. If there's at least a minimal uncertainty, the best thing to do is just start a new project aimed to increase your confidence. Think out the simplest task possible and get it done. Make it more and more complex unless it becomes what you really need. One can think it requires much more time, but the funny thing is - it always takes less than approach I described before.

Discover the power of "Hello World"

Whenever you start learning something new (or just about to do something you don't do every day), the best thing to do first is write a "Hello World". It's not because there's a tradition. It's because you need to test your adequacy first. You make sure you understand what you do. You make sure your environment is ready.

The power of "Hello World" is in its simplicity. The key point here is to take a task you're absolutely sure about and then get it done. If your confidence was reasonable, you'll get it confirmed. Otherwise, you'll realize that even a simplest program doesn't do what you expect it to do and this means that something is wrong.

Let's say you've never tried unit testing before and so one day you decide to check what JUnit is. It's a tool that runs pieces of code and every piece of code either fails or succeeds. It's that simple. So, the good "Hello World" is to write 2 tests: the empty one (to make sure it will never fail) and the failing one (to make sure it always fails). When you run these tests, you know what to expect. If your expectations were right, you'll make sure everything is fine. Otherwise, you'll have a great small illustration of how to make it not work.

Another good example is ORMs. You decided to learn Entity Framework. ORM is basically a tool to make your database interactions look like there are no database interactions at all. What you normally do to database is CRUD operations. So just take NUnit and write a test where you create something, read it, update it and then delete it. It's 20 lines of code and at most 1 hour of your time including googling, but you're now confident you know how to do it.

As long as you write Hello Worlds before making changes to the real code, there are just no complicated tasks for you. Don't be a hero. Just simplify the way you do it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer (Senior)
Russian Federation Russian Federation
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
GeneralMy vote of 5 Pin
Bronek22-May-13 11:09
Bronek22-May-13 11:09 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.