Difference between revisions of "Talk:Writer/Code Conventions"
From Apache OpenOffice Wiki
B michaelsen (Talk | contribs) (initial comments) |
(→hungarian prefixes: n,f,c,b, not a) |
||
Line 10: | Line 10: | ||
bjm: Why not for primitives? Keep in mind there are still the optional prefixes. | bjm: Why not for primitives? Keep in mind there are still the optional prefixes. | ||
+ | |||
+ | : For primitives (aka POD types) there are '''n''' for unsigned/int/long, '''f''' for double (hopefully float is not used ...), '''c''' for char and '''b''' for bool. Using '''a''' with those is just confusing and should be reserved for class object instances and similar. --[[User:ErAck|erAck]] 14:28, 9 October 2008 (CEST) | ||
+ | |||
= anonymnous namespace = | = anonymnous namespace = | ||
mst: imho anonymous namespaces in c++ are completely useless; just use static linkage instead | mst: imho anonymous namespaces in c++ are completely useless; just use static linkage instead | ||
bjm: why not both? That might at least help code analysis tools like lxr, autodoc, doxygen etc. | bjm: why not both? That might at least help code analysis tools like lxr, autodoc, doxygen etc. |
Revision as of 12:28, 9 October 2008
is/has-convention
bjm: Using the is/has convention for booleans allows writing code that reads like natural english:
if(m_isFileOpen && m_aSource.hasData() && their_isLoggingEnabled) lcl_writeLogEntry();
"If my file is open and my source has data and the logging for all SomeClass is enabled then write a log entry." an alternative would be our_ as prefix for static members.
if(m_isFileOpen && m_aSource.hasData() && our_isLoggingEnabled) lcl_writeLogEntry();
"If my file is open and my source has data and our logging is enabled then write a log entry."
hungarian prefixes
tl: Use the "a" prefix for class/struct values (not primitives like int, float, char, bool, ...) only.
bjm: Why not for primitives? Keep in mind there are still the optional prefixes.
- For primitives (aka POD types) there are n for unsigned/int/long, f for double (hopefully float is not used ...), c for char and b for bool. Using a with those is just confusing and should be reserved for class object instances and similar. --erAck 14:28, 9 October 2008 (CEST)
anonymnous namespace
mst: imho anonymous namespaces in c++ are completely useless; just use static linkage instead
bjm: why not both? That might at least help code analysis tools like lxr, autodoc, doxygen etc.