|
Birgitta, This attitude (and I'm not saying it is wrong, as I mostly agree with what you've said here) is one of the reasons an average RPG programmer may avoid subprocedures; People make things appear more complex than they really are using words like "encapsulation" gives them the impression that it is some strange new technology. They already know the simplicity of a subroutine, so if it works, why change? A subprocedure is a super-subroutine. They make subroutines obsolete. Use subprocedures instead of subroutines and you will be able to add function later, much more easily. And remember, "Deprecate, deprecates obsolete". -Bob -Bob Cozzi www.RPGxTools.com If everything is under control, you are going too slow. - Mario Andretti -----Original Message----- From: rpg400-l-bounces@xxxxxxxxxxxx [mailto:rpg400-l-bounces@xxxxxxxxxxxx] On Behalf Of HauserSSS Sent: Friday, June 24, 2005 12:49 PM To: RPG programming on the AS400 / iSeries Subject: AW: Assembly programmers do it a byte at a time Hi guys, sometimes I use subroutines to make my code more readable, i.e. programming a subfile with a confirmation subfile, that works like SAA-Standard. I'd never create a procedure, that cannot be encapsulated. To simply replace BEGSR through a P-statement and only use global variables does not make sense, in my opinion. A procedure or function must be encapsulated and only use local variables (with the exception of file information defined in the F-Specs). Because files defined in the F-Specs are always global, I prefer to use embedded SQL to make my data access local. All information comming from outside must be passed via parameter. All procedures or functions I write, get the keyword EXPORT. Even if today a procedure is only used once, I never know if I don't need it tomorrow or next year in a different context. All procedures are grouped into members depending on a common topic and converted into service programs. There are service programs that only contain Check-Procedures (i.e. for Item-No.) or that handle file access with native I/O etc. In this way the final source code of a program will be very small, because it only consists of a bunch of procedure calls. I think procedures and subroutines must coexist, but we have to use more and more procedures instead of subroutines. Birgitta -----Ursprungliche Nachricht----- Von: rpg400-l-bounces@xxxxxxxxxxxx [mailto:rpg400-l-bounces@xxxxxxxxxxxx]Im Auftrag von Joel Fritz Gesendet: Freitag, 24. Juni 2005 19:02 An: RPG programming on the AS400 / iSeries Betreff: RE: Assembly programmers do it a byte at a time Seems to me subroutines have a role. Because RPG has so many global variables, there are times when a procedure that uses globals requires the original programmer and anyone who modifies the code to pretend their values can't be changed by adding a line of code to the procedure that assigns a value directly. Passing by value can't defend against this. There are some ways around this by using a service program or a program call so the global is out of scope, but in a lot of cases it's not worth the trouble. Another feature of RPG that makes subroutines attractive is that file names and record format names can't be represented by string variables so truly generic file routines are impossible. A third thing is that RPG data types except the integer, float, and variable length character types have specific lengths. (I know, int and float types have length ranges.) It's much easier to write a procedure with arguments and return values that are more flexible than things like packed 5,2 or char 8. There are work arounds, but packed or signed decimals work a lot better with money than anything else available. Another factor, probably the root of it all, is that RPGIV has to be backward compatible with the RPG Classic static memory model. For small to medium programs I use subroutines for things that happen only once like beginning of program housekeeping stuff or things that modify a lot of global variables at once like a file write. I try to use procedures for everything else. I'm not saying you can't write a program that does everything with procedures. I believe that subroutines are sometimes a better tool for the job. They do provide functional decomposition and can be a tremendous aid in making a program extensible if they're well designed in the first place. The don't hide data, but there's a lot of data that's very hard to hide. > -----Original Message----- > From: rpg400-l-bounces@xxxxxxxxxxxx > [mailto:rpg400-l-bounces@xxxxxxxxxxxx] On Behalf Of Alan Campin > Sent: Thursday, June 23, 2005 4:45 PM > To: rpg400-l@xxxxxxxxxxxx > Subject: RE: Assembly programmers do it a byte at a time > >>>>>>>>>>>>>>>>>>>>> Big Snip <<<<<<<<<<<<<<<<<<<<<<<<<<<<< > > As far as subroutines being at some level of modularization, > I see what you are saying but I am uncomfortable with the > idea that subroutines are part of modularization. I still > have to use them with embedded SQL rather than doing /Free > and /End-Free all over the place but other than that, > subroutines should be dead, dead, dead. They provide nothing > that you really need to write good code. When we had nothing > else in RPG III, that was what you had but did not let you do > much of anything in software engineering. Makes me shudder to > remember the days of trying to write good code in > subroutines. Like living a long running nightmare. > -- > This is the RPG programming on the AS400 / iSeries (RPG400-L) > mailing list To post a message email: RPG400-L@xxxxxxxxxxxx > To subscribe, unsubscribe, or change list options, > visit: http://lists.midrange.com/mailman/listinfo/rpg400-l > or email: RPG400-L-request@xxxxxxxxxxxx > Before posting, please take a moment to review the archives > at http://archive.midrange.com/rpg400-l. > > ***************************** NOTICE: All e-mail sent to or from this e-mail address will be received or otherwise recorded by The Sharper Image corporate e-mail system and is subject to archival, monitoring, and review by and/or disclosure to Sharper Image security and other management. This message is intended only for the use of the addressee and may contain information that is privileged and confidential. The contents of this message may contain personal views which are not the views of The Sharper Image. If you are not the intended recipient, dissemination of this communication is prohibited. ***************************** -- This is the RPG programming on the AS400 / iSeries (RPG400-L) mailing list To post a message email: RPG400-L@xxxxxxxxxxxx To subscribe, unsubscribe, or change list options, visit: http://lists.midrange.com/mailman/listinfo/rpg400-l or email: RPG400-L-request@xxxxxxxxxxxx Before posting, please take a moment to review the archives at http://archive.midrange.com/rpg400-l.
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.