Personal tools

Coding guidelines

From MCRL2

Jump to: navigation, search

Contents

File hierarchy

The following describes how libraries and tools should be organised in a file hierarchy.

Libraries

Organisation of libraries:

Sub-directory Contents
build Library build files such as a Jamfile
doc Documentation (HTML) files
example Sample program files
include Header files
src Source files which must be compiled to build the library
test Regression or other test programs or scripts

Tools

Organisation of tools:

Sub-directory Contents
doc Documentation (HTML) files
test Regression or other test programs or scripts

Note: some of these guidelines were taken from [1].

Programming

Except for third party software, every header and source file should adhere to following guidelines.

Preamble

Every file should start with a preamble containing author names and links to copying and license information. The preamble should be formatted as follows, where AUTHORS stands for the names of the authors:

// Author(s): AUTHORS
//
// Copyright: see the accompanying file COPYING or copy at
// https://svn.win.tue.nl/trac/MCRL2/browser/trunk/COPYING
//
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)

Naming conventions

The following naming conventions regarding filenames should be used:

The following naming conventions regarding file contents should be used:

Header policy

The following guidelines are specific to header files (based on [2]):

The following is a sample header:

// Author(s): AUTHORS
//
// Copyright: see the accompanying file COPYING or copy at
// https://svn.win.tue.nl/trac/MCRL2/browser/trunk/COPYING
//
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
/// \file FILE_NAME
/// \brief BRIEF_DESCRIPTION
 
#ifndef MCRL2_MY_CLASS_H
#define MCRL2_MY_CLASS_H
 
namespace mcrl2 {
 
  class my_class
  {
    public: 
      void f();
    private:
      int x;
  };
 
} // namespace
 
#endif  // MCRL2_MY_CLASS_H

Exception handling

Use exceptions to report errors where appropriate, and write code that is safe in the face of exceptions.

Standards compliance

Aim for ISO Standard C++. That means making effective use of the standard features of the language, and avoiding non-standard compiler extensions. It also means using the C++ Standard Library where applicable.

Regression tests

Provide a regression test program or programs.

Usability

Provide sample programs or confidence tests so potential users can see how to use your library.

Platform independence

The source code must compile on the actively supported platforms and supported build tools on those platforms.

Committing changes

When committing changes, the following guidelines should be adhered to:

This page was last modified on 9 June 2009, at 16:14. This page has been accessed 27,203 times.
Copyright © 2005-2012 Technische Universiteit Eindhoven.
Powered by MediaWiki