Re: Code Complete 2 is now available!
From: Richard Potthoff (richard_potthoff_at_compuserve.com)
Date: 03/18/04
- Next message: José Mendizábal: "Re: Delphi Win32 alongside Delphi for .Net."
- Previous message: JED: "Re: I Can´t do it with Java,I can´t do it with C#."
- In reply to: Tom Reiertsen: "Re: Code Complete 2 is now available!"
- Next in thread: JED: "Re: Code Complete 2 is now available!"
- Reply: JED: "Re: Code Complete 2 is now available!"
- Reply: Anders Isaksson: "Re: Code Complete 2 is now available!"
- Reply: Charles Pope: "Re: Code Complete 2 is now available!"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Wed, 17 Mar 2004 20:40:08 -0500
There is no reason to indent the statements of a block again if "begin" and
"end" are already indented.
I normally indent 2 characters for the statement blocks, and 1 character for
"else", "except", etc.:
procedure SomeFunction;
var
condition1: boolean; {description1}
condition2: boolean; {description2}
begin
statement1;
if condition1 then
begin
statement2;
statement3;
end {if condition1 then}
else
statement4;
statement5;
statement6;
repeat
statement7;
statement8;
until condition;
statement9;
end; {procedure SomeFunction}
I sometimes use "begin" and "end" as formatting elements, even when it is
not syntactically required, e.g.:
if condition1 then
begin
if condition2 then
statement1
else
statement2
end {if condition1 then}
else
begin
statement3;
end; {if condition1 else}
statement4;
The result is a nice "blocky" structure.
Richard
"Tom Reiertsen" <tom@reiertsen.com> wrote in message
news:40560c78@newsgroups.borland.com...
> "Bear" <dogbear@163.net> wrote in message
> news:4053b99d$1@newsgroups.borland.com...
> > Manuscript for Code Complete 2 is now available! (pdf format)
> > It is here : http://www.stevemcconnell.com/cc2/cc.htm
> > but it will NOT be available soon !
> >
> > Code Complete 2 will be published in June 2004.
> >
>
> I have the original book and will probably buy the new one too, however,
> just the other day while I was reading the old one I discovered the
> following in the Code Styles chapter:
>
> "Avoid unindented begin-end pairs"
>
> I've always written Delphi code like this:
>
> procedure SomeFunction;
> begin
> Blabla..
> end;
>
> However, according to Steve McConnel this is bad. What do you guys think?
>
> You can all look at the examples given at around line 674 in this chapter
> (now in Java instead of Pascal, yuech!):
>
> http://www.stevemcconnell.com/cc2/31-LayoutAndStyle.pdf
>
> Tom.
>
>
- Next message: José Mendizábal: "Re: Delphi Win32 alongside Delphi for .Net."
- Previous message: JED: "Re: I Can´t do it with Java,I can´t do it with C#."
- In reply to: Tom Reiertsen: "Re: Code Complete 2 is now available!"
- Next in thread: JED: "Re: Code Complete 2 is now available!"
- Reply: JED: "Re: Code Complete 2 is now available!"
- Reply: Anders Isaksson: "Re: Code Complete 2 is now available!"
- Reply: Charles Pope: "Re: Code Complete 2 is now available!"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|