Every tutorial I've read for the last 30 years starts with the infamous 'Hello World' example. This could be one of the reasons we write crappy software. "Hello World" is the we make in every language. first program We can measure the complexity of language by counting the lines it takes to produce the desired output. We can also time how much does it take to a to figure out the solution (this is also known as " . newbie Time to hello world" (TTHW)) These two metrics are uncorrelated to productivity. Many sites compile different programs in a lot of languages. Hello World Helloworldcollection The Problems The example has a lot of problems introduced early when developers are making their first steps in programming. Hello Word It uses in many languages. Global functions are a code smell. Teaching them to newcomers in theirs first example is conflicting. globals yields (on the console, file system, printers, etc.). Hello World side effects We write the code, and we cannot test if it is working. We can manually check for the output, but our software cannot assert it our outcome was right. If our works today we cannot ensure it will keep working tomorrow. HelloWorld Code Smell 17 - Global Functions The Solution All developers should start with: { Assert( == ) } ( ) function testFalse 1 2 Advantages We start with a broken test. This is the first step to start developing software according to technique. test driven development We introduce developers to a pipeline with their very first instruction. Continuous Integration/Continuous Development We use no or side effects. Globals We show the importance of early testing. We stress how important is to have working code and from the very first second. automated tests How to Squeeze Test Driven Development on Legacy Systems Conclusion We need to stop writing as the first sentence of a language. HelloWorld Next time you come across a new fancy language, please start with a broken test.
Share Your Thoughts