On 7/8/2014 10:46 AM, John Yeung wrote:
So what Dieter and others are effectively saying is: The proper
design makes each variable as local as appropriate. In general,
smaller scope is preferable to larger scope (because it reduces the
chance of unintended side-effects), but that doesn't mean larger scope
is automatically bad.

There are very few absolutes in programming. No, a global variable is
not automatically a bad thing. I've just crossed my 36th year on the
midrange platform. Looking back in my mind's eye over the thousands -
tens of thousands - of RPG programs I've worked on, the odds of
'badness' track very well with the number of global variables.

I agree that module variables (like a DS that is used in a dozen
subprocedures) can be a reasonable design choice which simplifies
parameter lists; especially when we're talking about tramp variables
that are simply passed farther down the line and not actually used in
this subprocedure.

Were I starting a new design today, I would strongly consider
abstracting those references out of inline code and using setters and
getters instead. It's still global, but it also has unified error checking.
--buck

As an Amazon Associate we earn from qualifying purchases.

This thread ...

Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.