× 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.



I love it when somebody makes my argument better...

-----Original Message-----
From: rpg400-l-admin@midrange.com [mailto:rpg400-l-admin@midrange.com]On
Behalf Of Douglas Handy
Sent: Friday, December 07, 2001 2:23 PM
To: rpg400-l@midrange.com
Subject: Re: Cycle Processing vs. Doing it my way

Reeve,

>Understanding detail Lx and total Lx operations is pretty easy; I can't
>believe a programmer capable of dealing with pointers can't handle the
>cycle.

Exactly.  Sure there are some ugly cycle programs out there.  Just as there
are
ugly full-procedural programs out there.  But done right, using level breaks
can
make for *very* clean code which is *immediate* to understand at a glance.

(not to scale)

      * Define hierarchy of "level breaks", where L1 is lowest priority
     I                                 Foo   L2
     I                                 Bar    L1

      * Note: Records are read automagically by virtue of being a
      *           "primary" file, and RPG performs implicit comparisons
      *           to group records with identical "level break" contents

      * Handle change in "level break" field(s)
     C   L2            Exsr      NewFoo
     C   L1            Exsr      NewBar

      * Process input record
     C                   Exsr      ProcessRec

      * Process end of "level break" field(s)
     CL1               Exsr      EndFoo
     CL2               Exsr      EndBar
     CLR              Exsr      EndProgram

That's it.  The entire program mainline and total-time calcs.  What is so
hard
to teach about that?  EVERYTHING else belongs in a subroutine.  That's what
keeps this "readable" and easy to decipher.  I can tell at a glance exactly
what
field(s) define the level breaks.  And I can change them just as easily.
And I
don't have to follow the logic flow to ensure that a "higher priority" level
break cascades correctly to all lower levels.

I have a hard time believing that any programmer who is expected to learn to
maintain programs using pointers, API calls, yada, yada, can't learn how to
decipher what is happening above.

Heck, even if the programmer had never *heard* of the cycle but was handed
the
above program to make a change, I'd be sorely disappointed if they were at a
complete loss to know where to start.  They may not understand the "magic"
of
the "hidden" code, but if they can't make an educated guess by looking at
the
above, I'd have to wonder about their analytical skills.

Note that above I even break my prohibition against left-hand indicators.
This
is the one case where I think they are actually *more* readable than not
using
them.  (IMHO, you can get too pedantic about enforcing some rules.  The
exceptions are admittedly rare.  This is one of them, in my book.)

Doug

_______________________________________________
This is the RPG programming on the AS400 / iSeries (RPG400-L) mailing list
To post a message email: RPG400-L@midrange.com
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/cgi-bin/listinfo/rpg400-l
or email: RPG400-L-request@midrange.com
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 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.