Documente Academic
Documente Profesional
Documente Cultură
Table of Contents
What Coding Styles Are
Why Have Coding Style Guideline
Block Styles
C++ Styles
Class Styles
Comment Styles
Function Styles
Header Styles
Layout Styles
Name Styles
Variable Styles
Appendix - check list of styles to look for
Block Styles
Block Styles are all of the coding decisions related to code blocks. Code blocks are
lines of code surrounded by an opening brace ({) and a closing brace (}). If a software
engineer misunderstands reading where a code block begins and ends, they will
misunderstand what the code does.
C++ Styles
C++ Styles are all of the coding decisions related to techniques that exist in C++ but
not C. In most (if not all) cases, the C++ way of doing things is better than the C way of
doing things.
Class Styles
Class Styles are all of the coding decisions related to classes and objects. Object
oriented design is often the main reason that C++ is being used on a project, so making the
classes and objects easy to understand probably has the biggest impact on making future
maintenance easier.
constants
constructors
destructor
member functions
member variables
Types, constants and functions are placed closer to the top because everyone using the
class needs to read them. Member functions and variables are placed closer to the end
because only a software engineer maintaining this class needs to read them.
Comment Styles
Comment Styles are all of the coding decisions related to comments. Comments
explain what the code is doing. It is very important that they convey that information
accurately.
Function Styles
Function Styles are all of the coding decisions related to functions. These include
member functions which are often called methods.
Header Styles
Header Styles are all of the coding decisions related to header files.
Layout Styles
Layout Styles are all of the coding decisions related to white space. These include
spaces, tabs, line breaks, and any other invisible characters.
Name Styles
Name Styles are all of the coding decisions related to the choice of user defined
identifiers. These include names of files, macros, types, or variables.
Variable Styles
Variable Styles are all of the coding decisions related to variables. These include
member variables which are often called attributes.
C++ Styles
C++ cast
C++ source name
C++ struct
Class Styles
class layout
class operator
class variable
Comment Styles
comment DEBUG
comment end-of-line
comment grammar
comment header
comment in-line
comment line
comment TODO
Function Styles
function declaration
function parameter const
function parameter default
function parameter order
function parameter reference
function parameter unused
Header Styles
header content
header guard
header layout
header name
header needs #include
header paths
Layout Styles
layout function
layout indent
layout line breaks
layout non-function
layout operator
layout pointer declaration
layout reference declaration
layout semi-colon
layout tab
layout trailing backslash
layout trailing space
Name Styles
name acronym
name function
name leading underscore
name namespace
name variable
name type
Variable Styles
variable init
variable scope