Shortcut for chapter specific information

Monday, April 18, 2011

Correctness of programming

Sometimes you can have powerful conviction when you are doing fundamental training for yourself.   What I did today was to read he first few chapters of Gries' "Science of Programming".

For good and bad reasons, I have voluntarily/unvoluntarily programming for many years.   Unlike many wiz kids,  I wasn't natural in terms of computers.   My understanding of programming largely comes from "intuition".  

That's bad.

In fact, that could result in the worst type of programming technique - debugging by print.  It is the worst because you want to dump the guts of the program and you think that means you know what's going on.   Your feeling,  instead of logic, are playing a role.

What's the problem?  Well sometimes you can't print everything.  If the bad logic occurs in the inner loop, then you can potentially have display messages which cannot be analyzed.

The next worst thing is to program by debugger.  This is better than programming by print.   But still, when the programming is written, weren't you able to know where the potential issue come from already?

Then I start to meet good programmers.   The thing is most of them put much time upfront.  Instead of spending time in debugging the program.   Since they know, if you would like to be efficient in long run.  This is the way to go.

I read TCRC and then Gries.   Perhaps later I will read DEK (or finish reading.....).   Then I realize how much time I have been wasting in debugging.   That's not a bad conviction.   In a way, it is empowering.   It's a bit like you start to use a certain emacs macro correctly without retyping.   Or a unix command without manning the command.   Or start to use perl one-liner instead of a combination of awk/grep/sed.   This is powerful.

33_P

No comments:

Post a Comment