|
On 03/01/2006, at 10:32 AM, Mike Pantzopoulos - (H/O) wrote:
I have been having a major problem with the granularity (ie. size) of modules. Please consider the following: * Several sources I have read imply that a module should consist of a single sub-procedure.
Absolute bollocks! When RPG IV was first released it had an artificial restriction of 1 procedure per module. They corrected this (let's be generous) oversight by VRM320/VRM360 hence the use of the term sub-procedure to indicate multiple procedures.
I group related functions in a single service program. I may choose to use one or more modules in that service program and I will probably have more than one procedure in each module. For example:
DTS.SRVPGM DATE.MODULE getDate getDateTomorrow getDateYesterday TIME.MODULE getTime TS.MODULE getTimeStamp
* Creating a program or service program then binds (by copy/reference) so that a program could conceivably simply consist of source code which provides the framework for invoking numerous snippets of code via the individual sub-procedures.
If you put ALL your business logic in service programs then yes you could do this. The main line of each program would consist of nothing but procedure calls to service program functions (and possibly internal procedures).
However it is more likely that the program-specific code is kept in the program source and only truly common functions (i.e., used by more than one program or service program) are put in service programs. The *PGM main line would call internal procedures (in the same module or another module bound by copy) and external procedures in service programs. For example:
NEWPOLICY.PGM POLICY_LGC.MODULE business logic related to handling a new policy POLICY_DB.MODULEdatabase I/O related to handling a new policy (could be in a service program)
POLICY_PNL.MODULE screen handling related to a new policy DTS.SRVPGM common date/time/timestamp stuff plus any other common service programs you need
* As an old FORTRAN programmer, I'm happy with the concept oflinking like this. In essence, writing very small single focus functionsand then linking them through a binding step.
Same old same old.
* There is nothing to stop a module from containing numerous sub-procedures, both local to the module and EXPORTed.
True. Some level of relationship or cohesion should be used to decide which procedure goes in which service program.
o No EXPORT specified then private to this MODULEo EXPORT specified but not in BNDSRC then protected (i.e., private to this service program)
o EXPORT specified and in BNDSRC then public
* I can live with the idea of more than one sub-procedure in a module as long as they are only used locally, but I'm having trouble with the idea of modules with more than one sub-procedure. The compiler allows this to occur and to my mind it must be very difficult tracking the relationship between programs, modules, and sub-procedures.
No more difficult than dealing with 50 squillion copy members ala RPG II and III. As long as you use a sensible method of grouping related procedures in a service program you only have to worry about which modules are bound to which service program plus which modules are bound to which programs (should never be the same) and which service programs are bound to which other service programs or programs.
If you specify the modules on the CRTSRVPGM and CRTPGM commands and use binding directories to manage the service programs then you shouldn't run into too many management problems. Buy and use a decent change management tool that understands this stuff to make it easier.
All your developers need worry about is which procedure they want to use. A properly set-up development environment will handle most of the binding for them automatically. They don't have to concern themselves with where that procedure exists.
* My other beef with the module/sub-procedure relationship is the size of the name - if the sub-procedure name can be 15 and the source member name is 10, then we immediately have an issue. I am then faced with having to have a naming standard which encodes the sub-procedure name, or have to restrict my sub-procedure names to 10 characters.
Procedure names can be 4096 characters long so immediately you have a problem if you attempt to name the source member the same as the procedure. You would only do this IF you decided on a shop standard of one procedure per module but that would be a truly lame standard. Name the source member something generic. In the above examples that would be DATE, TIME, TS. Name the procedure within the source something descriptive. From the above examples that would be getDate, getDateTomorrow, getDateYesterday. Use business terms for the names of business-specific modules (e.g., POLICY, CUSTOMER, ITEM, WAREHOUSE, etc.) and put related code in these modules.
If you are concerned about name collisions or are just anal then supply a prefix to each procedure name. Others on this list have suggested using the module name as the prefix and if you do choose to specify procedure prefixes then this is as good as any. Thus our example procedure names would be DATE_GetDate, DATE_GetDateTomorrow, DATE_GetDateYesterday, POLICY_New, POLICY_Suspend, POLICY_Delete, etc.
Personally, I hate prefixes unless you can incorporate the prefix in the name proper (i.e., POLICY_Delete is OK but DATE_GetDate sucks) so even if I used them in a module (to avoid export collision) I would remove them via a suitable prototype and let my consumer decide whether they wanted to use the ugly prefix or not. For example:
/if defined(USE_UGLY_PREFIX) D DATE_GetDate PR D /else D getDate PR D EXTPROC(DATE_GetDate) /endif
Do other ILE developers restrict themselves to a single sub-procedure intheir modules?
No way! It's a dumb idea. Regards, Simon Coulter. -------------------------------------------------------------------- FlyByNight Software AS/400 Technical Specialists http://www.flybynight.com.au/ Phone: +61 3 9419 0175 Mobile: +61 0411 091 400 /"\ Fax: +61 3 9419 0175 \ / X ASCII Ribbon campaign against HTML E-Mail / \ --------------------------------------------------------------------
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2025 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.