|
Whether it is coded as isDomestic() or isInternational() they could both
return a false return.
Rather than say:
If not isInternational(phoneNumber);
I would use:
If isInternational(phoneNumber) = No;
This way the mind does not try to evaluate the NOT before the answer is
returned.
Sharon Wintermute
-----Original Message-----
From: rpg400-l-bounces@xxxxxxxxxxxx
[mailto:rpg400-l-bounces@xxxxxxxxxxxx] On Behalf Of Kurt Anderson
Sent: Monday, March 01, 2010 9:48 AM
To: 'RPG programming on the IBM i / System i'
Subject: RE: More on RPG style
There have been some comments about not issuing (or avoiding - to avoid
using the word "not") separate returns. In the case where I feel I need
to drop out of the procedure immediately instead of allowing logic
flowing to the end of the procedure, I'll typically create a "EndProc"
subroutine where I'll issue the Return and do any other end-of-procedure
type stuff I need done.
In regard to it being generally believed that "not" should not be used,
I guess I've overlooked that in the 8+ years I've been on this list. I
tend to believe that a procedure's return value, if an indicator, should
be '1' in the case where the procedure completed successfully.
If isInternational(phoneNumber);
However, there may be a case where I only care if it's not
international.
If not isInternational(phoneNumber);
Of course, I could also have instead called the procedure isDomestic()
so the return value would reflect whether it was Domestic or not
(instead of whether or not it was International).
If that makes any sense.
I guess I do my best to allow for readability, and don't want my code to
have "not"s all over the place, but if I feel I need to use one, it
doesn't make me step back and question my code. (Maybe it should?)
Thanks
Kurt Anderson
-----Original Message-----
From: rpg400-l-bounces@xxxxxxxxxxxx
[mailto:rpg400-l-bounces@xxxxxxxxxxxx] On Behalf Of David FOXWELL
Sent: Monday, March 01, 2010 4:44 AM
To: RPG programming on the IBM i / System i
Subject: More on RPG style
Hi,
I tend to divide my code into subprocedures in a program just to improve
readability, even when there is very little risk of that subprocedure
being called from anywhere else. Each subprocedure will correspond to a
specific task executed by the program.
Eg,
/FREE
IF not doThis ( )
RETURN
ENDIF;
IF NOT DoThat ( )
RETURN
ENDIF;
/END-FREE
In these cases I will use global variables unless not possible. That
leaves me with a load of one line prototype declarations in my code :
D doThis PR
D doThat PR
I've just discovered that this style seems to annoy at least one
programmer who prefers to see all the code in one main procedure and
does not like to see all those PR's PI's and returns, etc. Rather
embarassing.
Am I justified in coding in this way or am I wrongly using
subprocedures?
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.