Changes

Jump to: navigation, search

OOP344 - FjXR - 20102

97 bytes removed, 14:57, 31 May 2010
no edit summary
there’s no difference in where you place the opening parenthesis
for a multi-line definition:</p>
<br/>example:  int func(int a) {<br/> int b = a + 1;<br/> return b * 2;<br/> }<br/><br/><br/>
<p>and for a single-line definition that is often used for inlines:</p>
<br/>example: int func(int a) { return (a + 1) * 2; }<br/><br/>
<p>
Placing the ‘{‘ on the next line eliminates some confusing code
in complex conditionals, aiding in the scannability. Example:
</p>
<br/>example:  if(cond1<br/> && cond2<br/> && cond3) {<br/> statement;<br/> }<br/><br/>
<p>
The above has poor scannability. However,
</p>
<br/>example:  if (cond1<br/> && cond2<br/> && cond3)<br/> {<br/> statement;<br/> }<br/><br/><p>breaks up the ‘if’ from the body, resulting in better readability.
Finally, it’s much easier to visually align braces when they are
aligned in the same column. They visually "stick out" much
better.</p><br/><br/>
=== Identifier names ===
capitalizing each word. So a class looks like this:</p><br/><br/>
example: class FrenchVanilla : public IceCream {<br/><br/>
an object identifier looks like this:<br/><br/>
example: FrenchVanilla myIceCreamCone(3);<br/><br/>
and a function looks like this:<br/><br/>
example: void eatIceCreamCone();<br/><br/>
(for either a member function or a regular function).<br/>
=== Include guards on header files ===
and replacing the ‘.’ with an underscore. For example:</p><br/>
example:
<p> // IncludeGuard.h<br/>''' #ifndef INCLUDEGUARD_H'''<br/>''' #define INCLUDEGUARD_H'''<br/> // Body of header file here...<br/>''' #endif // INCLUDEGUARD_H'''<br/></p>
1
edit

Navigation menu