While I agree that modularity is the future path to easy redesigns, over modularizing an application can make the code even more difficult to comprehend than a top-down program with 10K lines and GOs every 20 lines. Anytime a section of code can be used elsewhere in the same program, but the scope of the code is too narrow to be changed to a global routine, then I make it an internal subroutine. Some people just don't know when to say when, though. I've seen programs that have 40 lines of main program code and 99% of them are GOSUBs. That is just a horrible way to design an application, IMO. Yes, it modularizes. It also makes the debugging developer continually jump from top to bottom of a 30K line program, trying to determine which of the 100 routines is being called at a certain run-time point, so you can find that one gremlin in the program that keeps bonking out. Even the best of comments don't always help here. When the code is broken up to that level of modularity, even single-use calculations can become internal subs in some people's minds.
---------------------------------------- Glen Batchelor IT Director All-Spec Industries phone: (910) 332-0424 fax: (910) 763-5664 E-mail: [EMAIL PROTECTED] Web: http://www.all-spec.com Blog: http://blog.all-spec.com ---------------------------------------- > -----Original Message----- > From: [EMAIL PROTECTED] [mailto:owner-u2- > [EMAIL PROTECTED] On Behalf Of Bessel, Karen > Sent: Wednesday, November 28, 2007 12:31 PM > To: u2-users@listserver.u2ug.org > Subject: RE: [U2] Deep and long indentations vs multiple exit points > > Subroutinize, subroutinize, subroutinize.... > > Flying geese should be avoided whenever possible. Those deep indents are > nearly impossible to read/maintain later on. > > -----Original Message----- > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] On Behalf Of Marco Manyevere > Sent: Wednesday, November 28, 2007 10:18 AM > 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/ ------- u2-users mailing list u2-users@listserver.u2ug.org To unsubscribe please visit http://listserver.u2ug.org/