Was: RPG passing parms to and from Rexx
On Wed, Aug 24, 2016 at 9:39 PM, Buck Calabro <kc2hiz@xxxxxxxxx> wrote:
We've all of us seen how programmers tend to copy examples verbatim
and try to use them without first studying them to obtain
understanding.
Ain't that the truth.
I've now become too cautious with my examples because of this. Which
is why the subject line reads as it does.
Well, I totally approve of the subject line you chose. I've tried to
follow that example by starting a new thread here.
And I do understand where the defensive style comes from, whether it's
writing examples or code used in production.
But for me, the fact that examples tend to be copied verbatim actually
reinforces my "strive for craftsmanship" mentality when I write them.
(This is in contrast to production code, which tends to be uglier but
hopefully more robust than examples.)
Since people are going to be copying verbatim, I worry that if I show them
action = 'Z';
coolAPI(action: data);
instead of simply
coolAPI('Z': data);
then when it comes time for them to try hooking it up to a dynamic
process, what they are going to write is
// Part of a loop that loads a new value into ACTCODE on each iteration:
action = actcode;
coolAPI(action: data);
instead of simply
coolAPI(actcode: data);
I mean, the extra step is not a crime. It's not even expensive. But I
don't really see what it gains, and I hate to encourage unnecessary
code. I guess just as you were traumatized by the thousands of
programs mindlessly following that compile-time array example, I am
traumatized by the thousands of useless lines of code that make
reading, debugging, and maintaining programs harder than necessary,
put there or left there by a culture of "why make it cleaner if it
works the way it is?". (And back when I was printing out compile
listings, imagine all the extra dead trees and prolonged goose chases
from not just the additional lines but the additional entries in the
reference section.)
Now, after saying all that, I timidly ask: What exactly was wrong with
the compile-time array example? I'll reproduce it here, since this is
a new thread:
Decades ago, there was a 'Teach yourself RPG' course; I can't remember
the company. They had an example of a compile time array that
traumatised me. They put the headings for a printed report in the
array. So the O-Specs were like
OQSYSPRT H 203 1P
O OR OF
O UDATE Y 10
O ARR,1 90
...
The reason this traumatised me isn't the example per se. It's the
fact that dozens; perhaps hundreds of RPG programmers took that
example as a way to do O-specs. I have personally witnessed this
pattern in thousands of programs, in multiple companies.
Let me back up. First of all, are you saying that they used the CT
array for the report title or for column headings? If the latter, then
was each heading its own array element, or were they glommed together
into one long element? And was ARR the actual name of the array?
What would have been a better way to write the O-specs?
I'm not trying to be snarky or to trap you. I'm not being willfully
stupid. And I am not disagreeing with your assessment of the example
or the resulting coding pattern either. I'm still gathering
information at this point.
John Y.
As an Amazon Associate we earn from qualifying purchases.