IMHO, using CASE as a replacement for IF's is extraneous. Meaning a harder
alternate than what should be the simpler form. CASE statements resolve to
being IF statements when compiled anyway.

CASE statements are best used for their original purpose. That is to
evaluate multiple conditions and only accept the first valid one and provide
an easy way to not consider the latter tests. Thus, each separate CASE
statement should have the thought process of individually being used instead
of just cascading all the negatives.

I believe the AND's in the IF statement are doing exactly what they are
intended to do. By expanding it into a CASE sequence distracts the reader.

BTW, one of my pet peeves with CASE statements is the blind addition of
these lines at the end: CASE 1 ; NULL.

While there are debates surrounding the use and value of NULL, adding CASE 1
; NULL for no purpose than to look pretty is, as some say, a waste of
cycles. It also distracts the programmer from considering that there is a
final catch all scenario when there really isn't any. It's like IF X=1 THEN
GOSUB 100 ELSE NULL. Not necessary.

My 2 cents.
Mark Johnson

BTW2. The use of END IF indicates someone coming from another non-MV
environment as END IF isn't MV required. I don't even know if it compiles.
----- Original Message -----
From: "Colin Jennings" <[EMAIL PROTECTED]>
To: <u2-users@listserver.u2ug.org>
Sent: Friday, November 30, 2007 9:36 AM
Subject: Re: [U2] Deep and long indentations vs multiple exit points


> > You could do this.
> >
> > PROCESS.REC:
> > ************
> >
> > READ RECORD FROM FILE,ID THEN
> >   IF RECORD<FLD.1> EQ COND1 AND RECORD<FLD.2> EQ COND2 AND RECORD<FLD.3>
> > EQ COND3 THEN
> >      RECORD<FLD.4> = 'PROCESSED'
> >      WRITE RECORD TO FILE, ID
> >   END IF
> > END IF
> >
> > RETURN
>
>
> Or, you could try:
>
> READ RECORD FROM FILE,ID THEN
>    BEGIN CASE
>    CASE RECORD<FLD,1> NE COND1
>    CASE RECORD<FLD,2> NE COND2
>    CASE RECORD<FLD,3> NE COND3
>    CASE 1
>       RECORD<FLD,4> = "PROCESSED"
>       WRITE RECORD ON FILE, ID
>    END CASE
> END
>
> For my money, the CASE statement, sensibly used, is much better than
> multiple IF statements
>
> Colin.
> -------
> u2-users mailing list
> u2-users@listserver.u2ug.org
> To unsubscribe please visit http://listserver.u2ug.org/
-------
u2-users mailing list
u2-users@listserver.u2ug.org
To unsubscribe please visit http://listserver.u2ug.org/

Reply via email to