ALICE O 2 C++ coding conventions Adriana Telesca on behalf of the CWG2 March, 21 st 2014
CWG2 ▶ Propose common guidelines, policies and procedures ▶ Conduct surveys for tools that cover the activities of most of the other working groups (aka Support tools) ▶ Coordinate other surveys ▶ Act as a central point where we keep track of who is evaluating what ▶ Ensure that resources are optimized and communication among the working groups is facilitated Tools, guidelines and procedures A. Telesca | CWG2 Tools, guidelines and procedures | 21/03/2014 2
CWG2 ▶ Adriana: DAQ, AMORE software development ▶ Alina: Offline, Offline software cycle organization ▶ Barth: DAQ, AMORE software development ▶ Ivana: Offline, AliRoot and Geant4 ▶ Matthias: HLT, Vc (SIMD types), Qt/KDE background, C++ committee work ▶ Vasco: DAQ, front-end applications and control software development Members A. Telesca | CWG2 Tools, guidelines and procedures | 21/03/2014 3
ALICE O 2 C++ coding conventions: why? ▶ O 2 as a fresh start ▶ However, contributions from many coders used to different conventions ▶ Need to ensure uniformity ▶ Need to adopt common conventions A. Telesca | CWG2 Tools, guidelines and procedures | 21/03/2014 4
ALICE O 2 C++ coding conventions: decision ▶ Google C++ coding guidelines as starting point ▶ Widely used conventions taken into account ▶ Herb Sutter and Stroustrup’s guidelines considered ▶ C++11 features ▶ Big effort invested The result is different from both Google and AliRoot A. Telesca | CWG2 Tools, guidelines and procedures | 21/03/2014 5
ALICE O 2 C++ coding conventions Two documents: ▶ Coding style Git: ▶ Naming ▶ Formatting ▶ Comments ▶ Coding guidelines Git: The documents A. Telesca | CWG2 Tools, guidelines and procedures | 21/03/2014 6
Coding style Goal A. Telesca | CWG2 Tools, guidelines and procedures | 21/03/2014 7
Coding style Naming and formatting A. Telesca | CWG2 Tools, guidelines and procedures | 21/03/2014 8
Coding style ▶ Naming ▶ Files ▶ Variables ▶ Functions ▶ Formatting ▶ Line length ▶ Classes Highlights A. Telesca | CWG2 Tools, guidelines and procedures | 21/03/2014 9
Code style Naming: General A. Telesca | CWG2 Tools, guidelines and procedures | 21/03/
Code style Naming: Files A. Telesca | CWG2 Tools, guidelines and procedures | 21/03/
Code style Naming: Variables A. Telesca | CWG2 Tools, guidelines and procedures | 21/03/
Code style Naming: Functions A. Telesca | CWG2 Tools, guidelines and procedures | 21/03/
Coding style Formatting: Line length and classes A. Telesca | CWG2 Tools, guidelines and procedures | 21/03/
Coding guidelines Goal A. Telesca | CWG2 Tools, guidelines and procedures | 21/03/
Coding guidelines A. Telesca | CWG2 Tools, guidelines and procedures | 21/03/
Coding guidelines ▶ Namespaces: ▶ General and std ▶ Scoping: ▶ Variables and Brace initialization ▶ Global variables ▶ Classes: ▶ Initialization ▶ Others: ▶ Exceptions Highlights A. Telesca | CWG2 Tools, guidelines and procedures | 21/03/
Coding guidelines Namespaces: general and std A. Telesca | CWG2 Tools, guidelines and procedures | 21/03/
Coding guidelines Namespaces: using declarations and directives A. Telesca | CWG2 Tools, guidelines and procedures | 21/03/
Coding guidelines Scoping A. Telesca | CWG2 Tools, guidelines and procedures | 21/03/
Coding guidelines A. Telesca | CWG2 Tools, guidelines and procedures | 21/03/
Coding guidelines Classes: Initialization A. Telesca | CWG2 Tools, guidelines and procedures | 21/03/
Coding guidelines A. Telesca | CWG2 Tools, guidelines and procedures | 21/03/
Coding guidelines Others A. Telesca | CWG2 Tools, guidelines and procedures | 21/03/
Feedback ▶ Received feedback/questions about: ▶ Templates ▶ STL usage ▶ Exceptions ▶ Threads ▶ Dependencies A. Telesca | CWG2 Tools, guidelines and procedures | 21/03/
Conclusion ▶ Lots of work and dedication ▶ This guide can be adapted following the usage of the C++ language that best suits the needs of the O 2 software. ▶ Your feedback will be considered for the next iterations of the document. A. Telesca | CWG2 Tools, guidelines and procedures | 21/03/
Questions ? 27 A. Telesca | CWG2 Tools, guidelines and procedures | 21/03/2014