I must admit I prefer multiple exit points, but I'll throw a third variant into the mix ...
OK = TRUE IF OK THEN Various statements that set OK to false if there's an error END IF OK THEN More statements that set OK to false if there's an error END Rinse and repeat RETURN Cheers, Wol -----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Marco Manyevere Sent: 28 November 2007 16:18 To: u2-users@listserver.u2ug.org Subject: [U2] Deep and long indentations vs multiple exit points There has been a lot said recently about styles, standards and good practice and I wonder what your take is on deeply indented routines with a common exit point versus unindented routines but with multiple exit points. I almost always prefer the later and find it much easier to follow. I come accross several routines or GOSUBs that get indented from line 1 right up to the end and I always change that to an early return and remove the indentation. Below are some examples: PROCESS.ID: READ RECORD FROM FILE, ID THEN * Several lines of indented code to calculate DESIRED.VALUE IF RECORD<FIELD.NO> EQ DESIRED.VALUE THEN * Several lines of even more indented code END END RETURN versus: PROCESS.ID: READ RECORD FROM FILE, ID ELSE RETURN END * Several lines of unindented code to calculate DESIRED.VALUE IF RECORD<FIELD.NO> NE DESIRED.VALUE THEN RETURN END * Several lines of unindented processing code RETURN Or LOOP READ RECORD FROM FILE, ID THEN IF RECORD<FIELD.NO> EQ 1 THEN * Processing code END END REPEAT UNTIL SOMECONDITION Versus: LOOP READ RECORD FROM FILE, ID ELSE CONTINUE END IF RECORD<FIELD.NO> NE 1 THEN CONTINUE END * Processing code REPEAT UNTIL SOMECONDITION ___________________________________________________________ Yahoo! Answers - Got a question? Someone out there knows the answer. Try it now. http://uk.answers.yahoo.com/ ------- 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/