|
Thankyou, Charles
I note that you too, are using global variables and that you are using sub-procedures as routines. Wouldn't it be nice to be able to do away with the prototype declaration for this kind of use? (!)
The mainline logic is clear and needs almost no commenting. I feel that most programmers I know would have put the whole thing into one main procedure.
I've been using this kind of notation more and more (thanks to Aaron Bartell) :
gDisplayFileControl.displaySubfile = ( gDtlSubfRrn > 0 );
-----Message d'origine-------
De : rpg400-l-bounces@xxxxxxxxxxxx
[mailto:rpg400-l-bounces@xxxxxxxxxxxx] De la part de Charles Wilt
Envoyé : lundi 1 mars 2010 14:24
À : RPG programming on the IBM i / System i
Objet : Re: More on RPG style
David,
I think you're justified. The important thing when doing
this is to give your procedures a descriptive name.
You've got 4096 characters to use, there's no excuse for
having short cryptic names. Don't be afraid to use the
ellipsis to create names longer than 15 characters.
d ORDER_AddLineItem...
d pr
I often use the ellipsis even with names less than 15
characters, as I often rename procedures during development
and if the ellipsis are already there renaming to a long name is easy.
Here's what I try to do, break the program into enough
routines so that the mainline fits on one screen (in WDSC of course).
In combination with descriptive procedure names, this allows a new
developer to easily get a handle on what the program does. For
example:
//
// Mainline logic
DoU gDisplayFileControl.exit
or gDisplayFileControl.cancel;
//
// Check for existing subfile records to condition SFLDSP
if gDtlSubfRrn > 0;
gDisplayFileControl.displaySubfile = *ON;
Else;
gDisplayFileControl.displaySubfile = *OFF;
endif;
gDisplayFileControl.subfileDropMode = dspfSubfMode;
Write MsgSubfCtl;
ExFmt DtlSubfCtl;
RmvMsgsFrmQ();
select;
when gDisplayFileControl.exit
or gDisplayFileControl.cancel;
iter;
when UserEnteredNewCriteria();
OpenCursor();
LoadSubFile(READ_START);
when gDisplayFileControl.printList;
PrintListing();
LoadSubFile(READ_START);
when gDisplayFileControl.pagedown;
LoadSubFile(READ_FORWARD);
when gDisplayFileControl.pageup;
LoadSubFile(READ_BACKWARD);
endsl;
enddo;
//
// End of program
*INLR = *ON;
return;
Tell me, what's the above?
HTH,
Charles
On Mon, Mar 1, 2010 at 5:44 AM, David FOXWELL
<David.FOXWELL@xxxxxxxxx> wrote:
Hi,just to improve readability, even when there is very little
I tend to divide my code into subprocedures in a program
risk of that subprocedure being called from anywhere else.
Each subprocedure will correspond to a specific task executed
by the program.
possible. That leaves me with a load of one line prototype
Eg,
/FREE
IF not doThis ( )
RETURN
ENDIF;
IF NOT DoThat ( )
RETURN
ENDIF;
/END-FREE
In these cases I will use global variables unless not
declarations in my code :
least one programmer who prefers to see all the code in one
D doThis PR
D doThat PR
I've just discovered that this style seems to annoy at
main procedure and does not like to see all those PR's PI's
and returns, etc. Rather embarassing.
subprocedures?
Am I justified in coding in this way or am I wrongly using
--(RPG400-L) mailing
This is the RPG programming on the IBM i / System i
list To post a message email: RPG400-L@xxxxxxxxxxxx To subscribe,please take a
unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxx Before posting,
moment to review the archives athttp://archive.midrange.com/rpg400-l.
--
This is the RPG programming on the IBM i / System i
(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.
This is the RPG programming on the IBM i / System i (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.