“My mind is clearer now. At last, all too well. I can see where we all soon will be”. – Judas in “Heaven on Their Minds” at the beginning of the rock opera “Jesus Christ Superstar”.
“My mind is in darkness now…” – Judas toward the end of the musical, after the betrayal for the 30 pieces of silver, and just before his suicide.
I’ve been working on a programming project – one I really should have done by now – and I’ve been feeling both of those emotions quite a bit lately. The project, for an unmentioned client, has been a mish-mash of decent to excellent programming styles, mixed with some of the worst I’ve seen for quite sometime.
This is pretty AS400/IBMi RPG specific, but here goes….
One of the key goals for the progression from “regular” RPG to RPGIV and eventually free format ILE RPG is the reduction in the reliance on indicators. Indicators are built in logical values, or flags, that were added to the original RPG programming language to aid with formatting reports and eventually (green screen) displays.
As the language grew, indicators were also relied upon for inline logic structures – you could check a variable’s value, set on an indicator, and then do something later in the program based on whether that indicator was on or off. The biggest problem with this approach was the resulting “spaghetti code” with all these scattered indicators controlling the execution of statements wildly and randomly in a program.
Over time, more logic constructs were added to the language so that indicators could be relied on less. By the time free format RPG made its debut, most programmers pretty much eliminated their use of indicators for logical decisions. They are still there, but their use has pretty much returned to formatting reports and screens.
However, bad programming style is still bad programming style. Replacing indicators with poorly named variables is not much of an improvement. When your favorite programming guru says “avoid using indicators” the real message may actually be something more like “make your program more readable”.
... some code ...
Is really not much different than
If wact = ‘Y’
... some code ...
You may know what “wact” is, but nobody else will without doing a search or using a split screen to keep definitions handy. Why not do something like
If cust_acct_status = “good”
... some code …
Old rule: “It was hard to write, so it ought to be hard to read”.
New rule: “Write programs so someone else can read them rather than just you. “
Copyright 2012 WallyDay.com
Click here for more information about 'Good Programmer, Bad Programmer'.