|
|
Home » Developing U++ » U++ Developers corner » is there U++ coding style reference?
Re: is there U++ coding style reference? [message #27780 is a reply to message #27768] |
Tue, 03 August 2010 11:24 |
|
kohait00
Messages: 939 Registered: July 2009 Location: Germany
|
Experienced Contributor |
|
|
dolik wrote:
Quote: |
Brackets are mostly on the same line
|
i disagree on that one . i have the impression that finding corresponding brackets is esier when they are placed on new line each. i know that Assist++ marks brackets, but it's also a visual perception of blocks, that matters, and here the new line stuff is better.
another thing:
small functions have their implementation in .h file anyway, and on same line as definition, like
Ctrl& Enabled(bool enable = true) { enabled = enable; return *this; }
rule of thumb: >3 syntactical important statements >> separate definition and implementation properly.
(syntactical important statements: real function calls and variable calculations, return values not counted, return *this is no 'important syntactical statement, only a helper.)
what about template classes?
.h / .hpp / .cpp relation and handling
did you look up my tempc class on that? any comments?
[Updated on: Tue, 03 August 2010 11:25] Report message to a moderator
|
|
|
|
|
|
Re: is there U++ coding style reference? [message #27789 is a reply to message #27788] |
Tue, 03 August 2010 13:39 |
|
I totally agree with mrjt and his reasoning.Morover, I am using 5 levels of color coded backgrounds (with quite sharp colors), that gives much better idea about blocks than looking forbrackets.
As I said before, the only exception to have bracket on separate line is the first bracket in function definition. I don't like that too much as well, but there I can see the reason - if you set the function name apart from the rest of text, it makes it easier to find the function when "scanning" through long file.
But I would never do this with if, while, etc. Actually I often make the block on the same line, if it contains just a short code:
if(condition){int a = 213;}
for(int i = 0; i < 123; i++){abs += i;} But that is my personal style, definitely not official U++
Honza
|
|
|
Re: is there U++ coding style reference? [message #27792 is a reply to message #27789] |
Tue, 03 August 2010 15:58 |
|
kohait00
Messages: 939 Registered: July 2009 Location: Germany
|
Experienced Contributor |
|
|
Quote: |
And assigning 123 to a in comparision without additional comment about intentionally doing so is not nice
|
that was a fast shot, i meant == ofcorse, where we are at the root of the problem .
some people even do stuff like
if(123 == a)
....
and
if(2 <= GetCount())
just to avoid this. i can see the good intention here but, honestly, if you found sth like that in code, you probably like i did, would have to twist your brain to grasp it.
this braces topic is, as we can see, really a question of taste and IMHO not too much affecting the overall code style. thats why i left it out in the code style section that i have uploaded some minutes ago.
please review, correct, add what ever is missing.
thanks
|
|
|
|
|
|
|
Goto Forum:
Current Time: Thu May 30 14:22:11 CEST 2024
Total time taken to generate the page: 0.01803 seconds
|
|
|