× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



At risk of drowning, I'll jump in here.

I assume that both isDocmestic() and isInternational() return an indicator (a Boolean). Then there is absolutely no need for readability to add the equality test. I find

if not isInternational() just as readable as

if isInternational()

and both are more readable, being just standard English, than

If isInternational() = No; (or maybe = *off;)

In fact, I have no trouble with NOT logic - I had a project manager for whom that twisted his brain. But if I have a condition for which I want to process only when it is not true, hey, I put that condition into a set of parentheses and put NOT in front of it - this is if it is a fairly complex set of ORs and ANDs - I find it much easier to conceive of the positive condition, then negate it. I prefer something like

NOT ((a = b) and (c = d))

to

((not (a = b) or not (c = d))

or, better than that and acceptable in this simple case,

((a <> b) or (c <> d))

But THAT still messes with my mind.

These are not complex enough to show the advantage, but it works for me.

JMHO
Vern

Wintermute, Sharon wrote:
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 thread ...

Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

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.