----- Original Message -----
From: "Scott Klement" <rpg400-l@xxxxxxxxxxxxxxxx>
To: "RPG programming on the AS400 / iSeries" <rpg400-l@xxxxxxxxxxxx>
Sent: Sunday, March 30, 2008 3:48 PM
Subject: Classic Traps -- I need your input!
Folks, I'm working on an article that's tentatively titled "Classic
Traps and How to Avoid Them". The general idea is to discuss the classic
mistakes that programmers make while programming, and (where necessary)
explain how to avoid that.
I would like to offer up two very related traps:
1 - Some programmers are very quick to jump to the decision to rewrite a
program or module from scratch when all that is needed is a simple fix. If
the original code is ugly, confusing, or simply outdated, these programmers
chose to reinvent the wheel rather than make the simple fix. Their tendency
to always rewrite often makes even seeing the simple fix more difficult.
2 - Other programmers are very hesitant to ever rewrite a program or module.
If the original code is ugly, confusing, or simply outdated, these
programmers often invest far more time attempting to retrofit a fix or
enhancement to the existing program than it would take to start from
scratch. Their tendency to never rewrite often makes even seeing the simple
fix more difficult.
"Always Rewriters" and "Never Rewriters" are very different programmers, but
you would be surprised how many people I have met at one extreme or the
other. You would be equally surprised by how few people I have seen whose
tendencies lie anywhere near the middle of the two.
As for How To Avoid, I have always tried to teach programmers at one extreme
or another to document why the other approach is not valid. Teaching
someone to have an open mind is not a trivial task, but when someone is
asked to justify their decisions they tend to at least consider the other
approach instead of blindly pushing forward.
FYI - I like to think I am near the middle of the two extremes, but in truth
I think I definitely lean toward the Always Rewrite side. When I come
across ugly code I find it hard not to replace it with something prettier or
more efficient. For example, yesterday I replaced 30+ lines of code that
determined the 'Quarter Number' for a given month. The routine worked just
fine, but it still bothered me... There are a dozen ways it could be done,
but I chose to use a pretty one-liner: Quarter=%div(Month:4) + 1;
Good luck with the article,
JD
As an Amazon Associate we earn from qualifying purchases.