Correct Delphi layout/design

Hi there

I've been using Delphi for many years and always thought of the correct layout.

Exmaple for If statements I use

If 1 = 1 then
  Begin
    { stagement }
  end
else
  Beigin
    If 2 = 2 then
      begin
        {statement}
      end;
  end;

--------

case i of
  1 : something
  2 : something else
  3 : begin something end;
else
end;

----

For i := 0 to count-1 do
  begin
    {statement}
  end;

---

So baically all the begin/end get tabed one in, and the statements get a further tab.

I find that is good for me, but is it 'proper'.

Your comments :)
LVL 10
wildzeroAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

mokuleCommented:
there will be war :)
for me proper is

If 1 = 1 then
   Begin
   { stagement }
   end
else
   Beigin
   If 2 = 2 then
      begin
      {statement}
      end;
  end;
0
JDSkinnerCommented:
Your block of if/else statements should read :-
if i = 1 then
begin
    < stagement >
end
else if i = 2 then
begin
    <statement>
end;

The case statement block does the same as the 'IF' construct but is a much neater structure.
You can use the Code Templates by pressing Ctrl + J when using the code editor to insert code methods.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
BlackTigerXCommented:
the recommended standard is how JDSkinner suggests, you put the begin on the next line and same column, and then TAB 2 spaces for the statements
0
BlackTigerXCommented:
just look at how the Delphi code is written, Ctrl+Click in (most) Delphi types like TForm, etc and check how the code is written and follow that
0
wildzeroAuthor Commented:
Sweet, thanks :D
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Delphi

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.