× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



On Tue, 24 Aug 2004 08:52:50 -0500, Lim Hock-Chai
<lim.hock-chai@xxxxxxxx> wrote:

> Joe L:
> For some reasons you seems to think that it is reaaaally bad to access/update 
> global variables from sub-proc.  I don't know about your shop, but if I apply 
> such a rule in my shop, I don't think I will be using sub-proc very often at 
> all.  All fields from F spec are global.  In most case, I need to use them in 
> most of my sub-proc.  If would be quite a pain if I've to pass them in every 
> time I need them.

Actually, it is not good practice for a SubProcedure to access global
variables.  SubProcedures were added to RPG as part of the ILE, in
order to allow for modular / object-oriented programming. 
SubProcedures should be standalone; any information should be passed
in or obtained independently by the SubProcedure.  These practices
come from the C++ ; the concept is called "encapsulation".

--> http://www.research.att.com/~bs/glossary.html


> I'm not saying that it is good to access/update them in sub-proc, but if you 
> design it correctly, it should be fine.

Certainly you can make it work, but that is at the expense of
re-usability and modularity.  If a sub-procedure requires global
variables, then it can only be used by programs which have those
global variables.

This distinction is clearest (and most necessary) for things like Mr.
Cozzi's toolset (xRPG?) and the CGIDEV2 service program.  The
SubProcedures can assume nothing about the calling program.  But it is
very relevant in the "custom" world as well.

How often have you had to bend over backwards to re-use a subroutine
because of all of the "setup" work required.  If the SR were a
properly isolated SubProcedure, the re-use is much easier.

-- 
Tom Jedrzejewicz
tomjedrz@xxxxxxxxx

As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:
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.