Delphi - Coding Standard?
I have to admit that I still only use about 50% of that document for my personal development stuff - but that's pretty good, considering that I never was taught any Delphi coding standards before ;-) In school we learned:
if ... then begin
....
end;
A lot of people did not like it and it is very visible. Thus, that was the first thing I changed.
5 Comments:
We have a corporate Coding Standard. We basically took the two "known" standards, the one written by Charlie and the one written by Xavier Pacheco and Steve Teixeira, and took from each what everyone on the team agreed with.
Fortunately for me, no one on my team can stand this:
if () then
begin
...
end;
So, thankfully, my begins are on the same line as my ifs. :D
By Anonymous, at 4:26 PM
Ok, I do not want to start a "war", but ...
After many years of Delphi development I personally prefer this style:
if () then begin
...
end else begin
...
end;
I always add "begin ... end" blocks as it happened too often to me that I added another instrucion, forgot to add begin/end and strange things happened ...
Having "begin" and "end else begin" each in only one line, using always begin/end does not add (additional) "dead" lines, i.e. begin/end in their own lines is pure waste of space ... and with today's IDEs screen space is a valuable asset !
IMHO the Object Pascal style with all the "begin", "else" and "end" in separate lines wastes too much space.
By Anonymous, at 12:46 AM
After reading the coding standard, I pretty much use all of them except: Yep, you guessed it - the begin .. end coding style.
I just can't change the habbit of:
if () begin
end
Like Levend I think its a waste of space to put the begin on its own line.
By Anonymous, at 8:07 AM
Hey, aren't you a member of the Indy core team? ;-)
Did you know that Indy has a coding standard as well?
http://www.indyproject.org/Sockets/Teams/Core/Docs/Standards/SourceCode.iwp
--
Regards,
Olaf
By Anonymous, at 2:48 PM
Hi Olaf,
you mean me as a member of Indy core team ?
No, I do not use a particular coding style because someone has told me to do so ... it's all the result of daily work.
I just had a quick look to the ObjectPascal coding style guide. While I agree with many things like casing standards etc., I heavily disagree with the begin-else-end style ... just check how many "dead" lines there are. Not to mention the extremly difficult readability when you always have to check, how many lines of code you now have to skip, as it simply does not add any functionality.
I must admit that I liked one paragraph very much as it helped me to solve a long lasting problem: how to indent Case-structures so that at the end the indentation level is ok again.
During various projects I saw many coding style conventions - some of them extremly strange (nearly disgusting).
BTW: did you ever check the coding style the MS Access wizards create ?
It's randomly indented, blank lines where you never would expect them and no blank lines where they would be appropriate ... and to make things even worse: I met some VB(A) developers that adopted this ugly wizard style !
I think Pascal developers usually produce extremly clean code when compared to VB or C/C++ developers (the latter seems to be applied cryptology <g>).
I once met a C/C++ guy who told me a funny story: when he was asked where he learned his clean coding style, he replied: "using Mr. Wirth's Pascal" ;-)
Levend.
By Anonymous, at 10:07 PM
Post a Comment
<< Home