I know this goes against common design standards, but I find the following
much easier to read with less clutter:

if something then begin
  dostuff
end else begin
  dootherstuff
end;

It's definately a personal thing, but as I always tend to use compound
statements I find the begin statement totally superfluous, so it just gets
in the way of readability if on a line of its own.

When the extra clutter is moved like this then 2 space indents is ample.

regards,
Steve


> -----Original Message-----
> From: Neven MacEwan [mailto:[EMAIL PROTECTED]]
> Sent: Wednesday, 19 September 2001 11:23
> To: Multiple recipients of list delphi
> Subject: Re: [DUG]: Help with Logic flows
> 
> 
> Steve
> 
> Yeah lets start the old begin end placement debate :-)
> 
> I use
> 
> If cond then
> begin
>    dostuff
> end
> 
> because of the old habit of finding the missing b/e in an editor that
> couldn't check
> but it gets messy with a block after else
> 
> If cond then
> begin
>   dostuff1
> end
> esle
> begin
>   dostuff2
> end
> 
> so sometimes i use
> 
> If cond then
> begin
>   dostuff1
> end
> esle begin
>   dostuff2
> end
> 
> which  lead me to the conclusion that I should
> 
> If cond then begin
>   dostuff1
> end
> esle begin
>   dostuff2
> end
> 
> HTH (sarcasm)
> 
> Neven
> 
> ----- Original Message -----
> From: "Steve Peacocke" <[EMAIL PROTECTED]>
> To: "Multiple recipients of list delphi" <[EMAIL PROTECTED]>
> Sent: Wednesday, September 19, 2001 11:05 AM
> Subject: Re: [DUG]: Help with Logic flows
> 
> 
> > ---------- Original Message ----------------------------------
> > >BTW any preferences for "begin end" layout?
> >
> > Most definately:
> >
> > if blah then
> > begin
> >     DoStuff;
> >     if Blat then
> >     begin
> >         DoSomething;
> >         DoOtherStuff;
> >     end
> >     else
> >         DoSomethingDifferent;
> > end;
> >
> > As you can see I totally agree with the other suggestions of using 4
> spaces for indenting - MUCH easier to view the program flow 
> and have been
> using it for years now.
> >
> > Also, by placing 'begin' in the same logical indentation as 
> both the 'if'
> and the 'end', the logical flow shows up better. this goes 
> also better with
> try/finally statements
> >
> > if blah then
> > try
> >     AttemptSomething;
> > finally
> >     FreeSomething;
> > end;
> >
> > You will have also noted with the first example, that else 
> is ALWAYS on a
> line of it's own. Note there is no ELSEIF statement in 
> Pascal. The transfers
> messy statements like
> >
> > if x=1 then
> >     Say(1)
> >     else if x=2 then
> >         say(2)
> >         else if x=3 then
> >             say(3)
> >             else say(4)
> >
> >
> > ...bastard of a statement. try the following:
> >
> > if x=1 then
> >     Say(1)
> > else
> > begin
> >     if x=2 then
> >         say(2)
> >     else
> >     begin
> >         if x=3 then
> >             say(3)
> >         else
> >             say(4);
> >     end;
> > end;
> >
> > This allows you to see what exactly will happen in any 
> given situation and
> just as important, you know which 'if' each 'else' responds to.
> >
> > Steve
> > 
> --------------------------------------------------------------
> ------------
> -
> >     New Zealand Delphi Users group - Delphi List - 
> [EMAIL PROTECTED]
> >                   Website: http://www.delphi.org.nz
> > To UnSub, send email to: [EMAIL PROTECTED]
> > with body of "unsubscribe delphi"
> > Web Archive at: http://www.mail-archive.com/delphi%40delphi.org.nz/
> >
> 
> --------------------------------------------------------------
> -------------
>     New Zealand Delphi Users group - Delphi List - 
> [EMAIL PROTECTED]
>                   Website: http://www.delphi.org.nz
> To UnSub, send email to: [EMAIL PROTECTED] 
> with body of "unsubscribe delphi"
> Web Archive at: http://www.mail-archive.com/delphi%40delphi.org.nz/
> 
---------------------------------------------------------------------------
    New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
                  Website: http://www.delphi.org.nz
To UnSub, send email to: [EMAIL PROTECTED] 
with body of "unsubscribe delphi"
Web Archive at: http://www.mail-archive.com/delphi%40delphi.org.nz/

Reply via email to