I know that C++ has something exactly like Leave. Its called Break. Its
used in the same way and does the exact same thing. I've used this in the
past. The place where I've seen it used the most is in terminating Case
statements. So this isn't just an RPG thing.
Thanks
Bryce Martin
Programmer/Analyst I
Ext. 4777
Jerry Adams <Jerry@xxxxxxxxxxxxxxx>
Sent by: rpg400-l-bounces@xxxxxxxxxxxx
01/12/2009 10:22 AM
Please respond to
RPG programming on the IBM i / System i <rpg400-l@xxxxxxxxxxxx>
To
RPG programming on the IBM i / System i <rpg400-l@xxxxxxxxxxxx>
cc
Subject
RE: Good places to use "The Cycle" in today's RPG
Chris,
I understand the comment about spaghetti code since, as a (more or less)
former RPG II programmer, I've seen multiple GOTO statements (in one case
I recall, dozens) that all pointed to the same TAG. That program, on
average, blew up once a week. It was a nightmare to debug (System/3 - no
STRDBG or such tool; just eyeballs).
As you correctly point out, the use of ITER/LEAVE is a matter of opinion
and preference. Others have already pointed out that ITER and LEAVE are
unlike GOTO's because of their built-in limitation.
In practice I use both methods. I do not find either, in most cases, more
or less understandable than its cousin. But I'll admit that I am the only
RPG programmer in this shop. My boss, who is a VB programmer (and other
such nonsense), has no problem reviewing my code (at least since I
switched to /free format a few years ago). I don't know if there are
ITERs or LEAVEs in VB or .Net, but the concept/purpose appears to be
easily grasped.
Jerry C. Adams
IBM System i Programmer/Analyst
B&W Wholesale
office: 615-995-7024
email: jerry@xxxxxxxxxxxxxxx
-----Original Message-----
From: rpg400-l-bounces@xxxxxxxxxxxx [mailto:rpg400-l-bounces@xxxxxxxxxxxx]
On Behalf Of Chris Pando
Sent: Friday, January 09, 2009 2:28 PM
To: RPG programming on the IBM i / System i
Subject: Re: Good places to use "The Cycle" in today's RPG
On Fri, Jan 9, 2009 at 1:35 PM, Marvin Radding
<marvin.radding@xxxxxxxxxxxxxxxxxxxxx> wrote:
... snip ...
Using leave or iter is good structured programming
If this thread has established anything, it's that
the sentiment above is a matter of opinion.
I fall into the 'use of ITER indicates lack of
analysis' camp. But that is just my opinion.
I don't believe LEAVE ad ITER are structured;
I developed a severe distaste for spaghetti code as
an RPGII programmer, and I believe use of LEAVE
and ITER leads to spaghetti code. Again,
just opinion, and stated as such (as opposed
to your statement of fact, above).
Chris
--
"Computer science is no more about computers
than astronomy is about telescopes."
- Edsger Dijkstra
As an Amazon Associate we earn from qualifying purchases.