Why Can’t Programmers.. Program? (from Coding Horror) quotes Reginald Braithwaite:
Like me, the author is having trouble with the fact that 199 out of 200 applicants for every programming job can’t write code at all. I repeat: they can’t write any code whatsoever.
“Codding Horror” lives up to its name:
After a fair bit of trial and error I’ve discovered that people who struggle to code don’t just struggle on big problems, or even smallish problems (i.e. write a implementation of a linked list). They struggle with tiny problems.
Write a program that prints the numbers from 1 to 100. But for multiples of three print “Fizz” instead of the number and for the multiples of five print “Buzz”. For numbers which are multiples of both three and five print “FizzBuzz”.
Most good programmers should be able to write out on paper a program which does this in a under a couple of minutes. Want to know something scary? The majority of comp sci graduates can’t. I’ve also seen self-proclaimed senior programmers take more than 10-15 minutes to write a solution.
What can I say? For now: Meh!!
BTW: posted on Feb 26, that Horror story has received a bazillion comments.
Am I stuck thinking ML patterns? I came up with this:
i=0
for j = 1 to 7
i=i+1
print i
i=i+1
print i
i=i+1
print “Fizz”
i=i+1
print i
i=i+1
print “Buzz”
i=i+1
print “Fizz”
i=i+1
print i
i=i+1
print i
i=i+1
print “Fizz”
i=i+1
print “Buzz”
i=i+1
print i
i=i+1
print i
i=i+1
print “Fizz”
i=i+1
print i
i=i+1
print “Fizz, Buzz, Brrap”
next j
Ok, fine, it ends at 105. So sue me.
p.s. Back in the day I pressed to implement my WRO … “Write Right, Once”. Thas was years ago. Just now, in “Horrors“, I came aross step #11 from the Pragmatic Programmers’ Quick Reference and guess what: “DRY–Don’t Repeat Yourself – Every piece of knowledge must have a single, unambiguous, authoritative representation within a system”. Yaa, that!