Thursday, February 28, 2013

Code Complete - Target Audience For Code

Twice today I read quotes or paraphrases of a statement from the book Code Complete by Steve McConnell, "Write Programs for People First, Computers Second".

I certainly understand that, I've been doing maintenance programming for the past 20 years, so I know what it means to be the human/programmer audience for code.  I know how hard it is to read bad code and how hard it is.  I'm also fully aware that a lot of code that is hard for people to read is often buggy so though the computer understands it, the computer doesn't end up doing what the people would prefer it was doing.

And I know what it's like to work with a guy who refuses to write easy-to-read code angrily telling anyone who gives him feedback, "I don't care! If someone is too stupid to understand this, then that's not my problem!"

It's not that I don't know what it means…

However, thinking about the statement itself…

If the computer isn't your first target "audience" for the code you write, why are you writing it?  You might as well not write code if it isn't primarily for the computer to execute.

That database code?  If the computer is only your second choice as a target, how about hiring some file clerks and giving them the instructions?

That graphics program you're writing, if the computer isn't your main audience, how about going and buying some top quality pencils, brushes and paints and go out in the fresh air instead of sitting on your butt in front of the computer?

So, really, if the computer isn't your primary target, you should write the code at all.

That said, of course, once you're committing to writing code to solve the problem, by all means write it so the next poor schmuck can read it and understand it (bearing in mind, that next poor schmuck might very well be you in a short while…)

No comments:

Post a Comment