|
On Tue, 24 Aug 2004 17:01:07 +0000, Joel Cochran <jrc@xxxxxxxxxx> wrote: > > Encapsulation is a great idea when applied properly. And this article > should prove I think this can be done in RPG: > > http://www.midrangeserver.com/fhg/fhg072104-story01.html Cool link, great article. > However, there is nothing wrong with internal sub-procedures accessing > global program variables. You are trying to apply a C++ OO standard to > a procedural language, and frankly it just doesn't follow. Remember we > are talking about sub-procs WITHIN a program here, not in another > *MODULE. As such, you may find that you are required to use global > variables. I concede about the global variables, although I do maintain that it should be avoided. The SQL issue (you cite below) is in my view an implementation problem. My point was that SubProcedures were created to allow for encapsulation and other OO concepts to be implemented more easily using RPG, and also in a manner consistent with other languages. There is no huge benefit to using them in place of EXSR other than to become more familiar. > Take embedded SQL for example: try putting an SQL statement in a > sub-procedure that uses a local variable. It just isn't happening. And > as others pointed out, the fields from a file defined in an 'F' spec are > global without question. I like to "encapsulate" my screen access for > standard file maintenance in sub-procedures, but this means the screen > variables (and the file variables) are global. Makes sense, but in that case there is little difference between a SubProcedure and a SR. I think that winds around to where I was going. There is very little functional difference between a SR and an internal SubProcedure. The real value of SubProcedures is that they allow for changing the DESIGN of the applications to use encapsulation, OO concepts, and improving reusability and modularity. Back to the very start here . . . if the guy has designed his application already, is writing code, and is wrestling with the decision of whether to use SubProcedures or EXSR, he is too late and at that point it really doesn't matter. > > 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. > > This is, in fact, the point of sub-procs, but not what this discussion > was about. I guess I was trying to take it there . . . -- Tom Jedrzejewicz tomjedrz@xxxxxxxxx
As an Amazon Associate we earn from qualifying purchases.
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.