C++ coding convention change

48 views
Skip to first unread message

Stephen E. Baker

unread,
Aug 6, 2015, 9:29:28 AM8/6/15
to corsix...@googlegroups.com
I've removed the requirement for Hungarian notation (type prefixes) from
our C++ coding convention guide. The practice is rarely used anymore in
the wild, causes difficulties in refactoring, and is counter to the
notion of templates, generics, and even inheritance. Beyond the extra
work in implementing and maintaining them, the benefits are dubious as
every IDE is able to provide type information and access to a variable's
definition.

I think it may be worthwhile extending the C++ coding convention to cover:
Using namespace prefixes (std::) on C library functions and types.
Avoiding macros in favor of inline functions, templates, and cost variables.
Using explicitly sized primitives (cstdint types.)
Using nullptr instead of 0 or NULL for null pointers.
Preferring stack allocation to heap allocation unless impractical (large
memory requirement, out of stack references, etc.)
Using smart pointers when heap allocation is used.
Using bracket construction (uniform initialization.)
Using initialization lists or default member values over setting member
values in the constructor body.
(more?)

Reply all
Reply to author
Forward
0 new messages