Difference between revisions of "Cpp Coding Standards"

From Apache OpenOffice Wiki
Jump to: navigation, search
m
m (Purpose: Typo fixed.)
 
(17 intermediate revisions by one other user not shown)
Line 1: Line 1:
Note: The subpages of this page are work in progress.
 
      There may be some inconsistencies until
 
      Wednesday, Nov 29 2006.
 
 
 
=== Purpose ===
 
=== Purpose ===
[[Coding standards]] are a part of [[defect prevention]]. They gather rules, advice and best practices for developing software, especially the code writing part. Here are listed some ideas what such standards could be for developing with C++ and within the [[OpenOffice.org]] project.  
+
[[Coding Standards]] are a part of [[defect prevention]]. They gather rules, advice and best practices for developing software, especially the code writing part. Here are listed some ideas what such standards could be for developing with C++ and within the [[OpenOffice.org]] project.
  
 
=== Standards and Reviews  ===
 
=== Standards and Reviews  ===
 
Coding standards and reviews are related. Reviews help getting to know standards and bringing them into the real life of the code. Reviews also help to improve standards and disclose needed changes.
 
Coding standards and reviews are related. Reviews help getting to know standards and bringing them into the real life of the code. Reviews also help to improve standards and disclose needed changes.
  
The standards are parted into topics. Each topic is intended to cover an area that is small enough to be the focus of a code review session. The summary of rules regarding one topic should not cover more than "one page" of paper or on screen. This way one topic's summary can be printed out and be used as checklist when studying code.
+
The standards are parted into topics. Each topic is intended to cover an area that is small enough to be the focus of a code review session. The summary of rules regarding one topic should not cover more than "one page" of paper or on screen. This way one topic's summary can be printed out and be used as checklist when studying code.
 +
 
 +
To print a summary page out of this wiki such that it fits on one page indeed, select the text of the rule summaries (all text below the content table) and print using the option "print selection".
  
 
Most times a summary alone is not enough to understand and discuss a rule, also there are exceptions and hints for realization. So, for each rule there will be a separate wiki page to discuss it.
 
Most times a summary alone is not enough to understand and discuss a rule, also there are exceptions and hints for realization. So, for each rule there will be a separate wiki page to discuss it.
  
 
=== Identifying Rules ===
 
=== Identifying Rules ===
Ids enable to make notes about rules (e.g. during reviews) and help when talking about them. Because items may be added or sorted out, such ids are not just cardinal numbers, but strings that do not change, when other items are added or removed. Each topic has an id, and each rule within the topic has an id itself.
+
Every topic and each item have an id.
  
Example: [[/FDESIGN#OneTask | FDESIGN:OneTask]] is the rule with the id "OneTask" which belongs to the topic [[/FDESIGN|Function Design]] with the id "FDESIGN".
+
Ids enable to make notes about rules (e.g. during reviews) and help when talking about them. The ids are not just cardinal numbers, but strings, because strings do not change, when other items are added or removed.
 +
 
 +
Example: [[/FDESIGN#OneTask | FDESIGN:OneTask]] is the rule with the id ''OneTask'' which belongs to the topic [[/FDESIGN|Function Design]] with the id ''FDESIGN''.
  
 
----
 
----
Line 23: Line 23:
 
''Topics may appear at multiple domains.''
 
''Topics may appear at multiple domains.''
  
==== Middle- and Lowlevel Design ====
+
==== Design ====
* [[/Design|Design]] (DESIGN)
+
* [[/DESIGN|Design]] (DESIGN)
* [[/Virtual Classes|Virtual Classes]] (VIRTUAL)
+
* [[/VIRTUAL|Virtual Classes]] (VIRTUAL)
* [[/Class Design|Class Design]] (CLSDESIGN)
+
* [[/CLSDESIGN|Class Design]] (CLSDESIGN)
* [[/Interfaces|Interfaces]] (IFC)
+
* [[/IFC|Interfaces]] (IFC)
* [[/Function Design|Function Design]] (FDESIGN)
+
* [[/FDESIGN|Function Design]] (FDESIGN)
  
 
==== Classes ====
 
==== Classes ====
* [[/Class Design|Class Design]] (CLSDESIGN)
+
* [[/CLSDESIGN|Class Design]] (CLSDESIGN)
* [[/Virtual Classes|Virtual Classes]] (VIRTUAL)
+
* [[/VIRTUAL|Virtual Classes]] (VIRTUAL)
* [[/Interfaces|Interfaces]] (IFC)
+
* [[/IFC|Interfaces]] (IFC)
* [[/Encapsulation|Encapsulation]] (ENC)
+
* [[/ENC|Encapsulation]] (ENC)
* [[/Class Construction, Destruction and Copying|Class Construction, Destruction and Copying]] (CLSINIT)
+
* [[/CLSINIT|Class Construction, Destruction and Copying]] (CLSINIT)
* [[/Function Design|Function Design]] (FDESIGN)  
+
* [[/FDESIGN|Function Design]] (FDESIGN)  
  
 
==== Functions and Implementation Generally ====
 
==== Functions and Implementation Generally ====
* [[/General Coding|General Coding]] (GEN)  
+
* [[/GEN|General Coding]] (GEN)  
* [[/Function Design|Function Design]] (FDESIGN)  
+
* [[/FDESIGN|Function Design]] (FDESIGN)  
* [[/Function Implementation|Function Implementation]] (FIMPL)  
+
* [[/FIMPL|Function Implementation]] (FIMPL)  
* [[/Error Handling|Error Handling]] (ERR)  
+
* [[/ERR|Error Handling]] (ERR)  
* [[/Security|Security]] (SECURITY)
+
* [[/SECURITY|Security]] (SECURITY)
  
 
==== Preferred vs. Discarded Types and Habits ====
 
==== Preferred vs. Discarded Types and Habits ====
 
* [[/STL|The C++ Standard Template Library]] (STL)
 
* [[/STL|The C++ Standard Template Library]] (STL)
* [[/Type Safety|Type Safety]] (TYPE)  
+
* [[/TYPE|Type Safety]] (TYPE)  
* [[/Obsolete Habits|Obsolete Habits]] (OBSOLETE)  
+
* [[/OBSOLETE|Obsolete Habits]] (OBSOLETE)  
  
 
==== Files, Formatting, Documentation ====
 
==== Files, Formatting, Documentation ====
* [[/Code Format|Code Format]] (FORMAT)
+
* [[/CODEDOC|Code Documentation]] (CODEDOC)
* [[/Header Files|Header Files]] (HEADERS)
+
* [[/HEADERS|Header Files]] (HEADERS)
* [[/Code Documentation|Code Documentation]] (CODEDOCU)
+
* [[/FORMAT|Code Format]] (FORMAT)
 
+
==== Principles and Process ====
+
* [[/Principles|Principles]] (PRINC)
+
* [[/Development Process|Development Process]] (PROCESS)
+
 
----
 
----
  
 
=== Topics in Alphabetical Order ===
 
=== Topics in Alphabetical Order ===
* [[/Class Construction, Destruction and Copying|Class Construction, Destruction and Copying]] (CLSINIT)
+
* [[/CLSINIT|Class Construction, Destruction and Copying]] (CLSINIT)
* [[/Class Design|Class Design]] (CLSDESIGN)
+
* [[/CLSDESIGN|Class Design]] (CLSDESIGN)
* [[/Code Documentation|Code Documentation]] (CODEDOCU)
+
* [[/CODEDOC|Code Documentation]] (CODEDOC)
* [[/Code Format|Code Format]] (FORMAT)
+
* [[/FORMAT|Code Format]] (FORMAT)
* [[/Design|Design]] (DESIGN)
+
* [[/DESIGN|Design]] (DESIGN)
* [[/Development Process|Development Process]] (PROCESS)
+
* [[/ENC|Encapsulation]] (ENC)
* [[/Encapsulation|Encapsulation]] (ENC)
+
* [[/ERR|Error Handling]] (ERR)  
* [[/Error Handling|Error Handling]] (ERR)  
+
* [[/FDESIGN|Function Design]] (FDESIGN)  
* [[/Function Design|Function Design]] (FDESIGN)  
+
* [[/FIMPL|Function Implementation]] (FIMPL)  
* [[/Function Implementation|Function Implementation]] (FIMPL)  
+
* [[/GEN|General Coding]] (GEN)  
* [[/General Coding|General Coding]] (GEN)  
+
* [[/HEADERS|Header Files]] (HEADERS)
* [[/Header Files|Header Files]] (HEADERS)
+
* [[/IFC|Interfaces]] (IFC)
* [[/Interfaces|Interfaces]] (IFC)
+
* [[/OBSOLETE|Obsolete Habits]] (OBSOLETE)  
* [[/Obsolete Habits|Obsolete Habits]] (OBSOLETE)  
+
* [[/SECURITY|Security]] (SECURITY)
* [[/Principles|Principles]] (PRINC)
+
* [[/Security|Security]] (SECURITY)
+
 
* [[/STL|The C++ Standard Template Library]] (STL)
 
* [[/STL|The C++ Standard Template Library]] (STL)
* [[/Type Safety|Type Safety]] (TYPE)  
+
* [[/TYPE|Type Safety]] (TYPE)  
* [[/Virtual Classes|Virtual Classes]] (VIRTUAL)
+
* [[/VIRTUAL|Virtual Classes]] (VIRTUAL)
 +
----
 +
 
 +
=== Guidelines ===
 +
''Not easily checkable or not code related.''
 +
 
 +
* [[/Principles|Principles]] (PRINC)
 +
* [[/Development Process|Development Process]] (PROCESS)
 +
* [[/Advice|Advice]] - (ADVICE)
 +
 
 
----
 
----
 
[[Category:Coding Standards]]
 
[[Category:Coding Standards]]

Latest revision as of 09:31, 14 June 2007

Purpose

Coding Standards are a part of defect prevention. They gather rules, advice and best practices for developing software, especially the code writing part. Here are listed some ideas what such standards could be for developing with C++ and within the OpenOffice.org project.

Standards and Reviews

Coding standards and reviews are related. Reviews help getting to know standards and bringing them into the real life of the code. Reviews also help to improve standards and disclose needed changes.

The standards are parted into topics. Each topic is intended to cover an area that is small enough to be the focus of a code review session. The summary of rules regarding one topic should not cover more than "one page" of paper or on screen. This way one topic's summary can be printed out and be used as checklist when studying code.

To print a summary page out of this wiki such that it fits on one page indeed, select the text of the rule summaries (all text below the content table) and print using the option "print selection".

Most times a summary alone is not enough to understand and discuss a rule, also there are exceptions and hints for realization. So, for each rule there will be a separate wiki page to discuss it.

Identifying Rules

Every topic and each item have an id.

Ids enable to make notes about rules (e.g. during reviews) and help when talking about them. The ids are not just cardinal numbers, but strings, because strings do not change, when other items are added or removed.

Example: FDESIGN:OneTask is the rule with the id OneTask which belongs to the topic Function Design with the id FDESIGN.


Topics by Problem Domain

Topics may appear at multiple domains.

Design

Classes

Functions and Implementation Generally

Preferred vs. Discarded Types and Habits

Files, Formatting, Documentation


Topics in Alphabetical Order


Guidelines

Not easily checkable or not code related.


Personal tools