Title: Message

I don’t think it is more readable, especially at a glance.

 

I think

 

If Enabled

   A := 1

Else

   A := 2;

 

Is much more readable than including the begin ends.

 

Obviously all personal preference. If you look at the Delphi help or example code written by Borlanders on the BDN site it is interesting that even they have different approaches to begin end blocks, some choose option A from below some use option B.

 

I prefer

 

If Enabled

Begin

End;

 

Rather than

 

If enabled begin

End;

 

To me its more logical to have the begin and end in a line so you can see which block the code belongs to.

 


From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Like Magic
Sent: Saturday, 24 January 2004 12:02 p.m.
To: 'NZ Borland Developers Group - Delphi List'
Subject: RE: [DUG] Optional Main Form

 

I also use begin/end blocks for readability. If the code is easy to read - it is easier to maintain and less likely to have coding errors in the first place especially with loops and if statements.

The downside is it requires a little more typing but you were going to do that for your documentation any way :-)

 

Maurice

-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]On Behalf Of Ross Levis
Sent: Friday, 23 January 2004 11:28 p.m.
To: NZ Borland Developers Group - Delphi List
Subject: Re: [DUG] Optional Main Form

> IMHO, I'd consider the use of begin..ends essential in any Delphi Coding Standard doco. ;-)

Why make it more complex than it needs to be?

 

if Enabled then a := 1 else a := 2;

Compare that to:

 

if Enabled then begin

  a:=1;

end

else begin

  a:=2;

end;

I would imagine this generates more code and would be slower.  In my opinion, begin/end blocks are designed for when more than one statement is required.

 

Regards,

Ross Levis

_______________________________________________
Delphi mailing list
[EMAIL PROTECTED]
http://ns3.123.co.nz/mailman/listinfo/delphi

Reply via email to