|
Bob Cagle wrote: > > I'm looking for some ammo, guys! > > I personally have been using RPGIV and sub-procedures, service programs, > etc. since '96. But I am running into an ever increasing number of > programmers that ask the basic question "Why use a sub-procedure when it > does the same thing as a program call?" > If the routine is totally self-contained, so that it only depends on its parameters plus possibly some non-parameter that ONLY that routine uses, then it could easily be either a program or a subprocedure. I think the main advantage of using subprocedures instead of programs is for the sharing of data between routines. Say you have a set of routines (say RTN1 - RTN8) that all use the same data structure. If you have those routines in separate programs, you have to pass the structure around between the RTN* programs, AND you have to give the data structure to say PGM1 that will call into the RTN* programs, even though PGM1 might not need it. If you have these routines in one module, they can easily share the data without parameters. If you change the data structure, you have to recompile all the RTN* programs. If all the RTN* routines were in a single module, you'd only have one recompile - and you wouldn't have to wonder if you found all the dependencies because it would be obvious that the DS was local to the module. A similar situation is a utility routine U1 used by several other routines X1-X8. If all X1-X8 and U1 are in the same module, U1 can be kept private to the module. If you need to change the interface to U1, you only need to change that one module. If U1 is a program, anything can call it. For me, the next biggest advantage of procedures is just the ability to have more than one procedure in a module, even if they don't actually share anything. The thought of having a separate source file for each routine ... brrrr.
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.