wiki:Documentation/DevelopmentCenter/DeveloperGuidelines

HeuristicLab Development Guidelines

1. General

  • Any documentation has to be written in English. This includes all documents, wiki-pages, commit messages, code comments, ticket descriptions, ...
  • Names of plugins, namespaces, classes, structs, enums, methods, properties, variables, ... are in English.
  • C# is used as programming language.

2. Coding Standards

HeuristicLab code should be conform to the guidelines described in Design Guidelines for Developing Class Libraries.

To ensure consistent formatting of the source code, developers should use identical settings for the Visual Studio Text Editor. The appropriate settings are attached to this page and should be imported in Visual Studio. Additionally a list of useful Visual Studio 2010 extensions which help to ensure the coding standard, is compiled on this page.

2.1. Indentation

  • 2 spaces, no tabs

2.2. New Lines and Blocks

  • Opening braces ({) are on the same line of the statement which opens the block.
  • Closing braces (}) are on a new line after the last statement of the block.

2.3. Naming

  • All identifiers are written in CamelCase.
    • Do not use _ in identifiers.
    • Do not use Hungarian notation (e.g. iCount for an int counter or dFactor for a double factor).
  • Casing:
    • Classes, interfaces, properties, and methods start with an uppercase letter (e.g. Sheep, Weight, LookABitSilly).
    • Fields, method parameters, and local variables start with a lowercase letter (e.g. sheep, weight, i).
  • Names:
    • Interfaces start with an I (e.g. IItem, IOperator).
    • Abstract base classes are not suffixed by Base (e.g. Item, Operator, Engine).
    • The name of each HeuristicLab plugin starts with HeuristicLab.
    • The name of a plugin has to be identical to the project name and the namespace of the plugin (e.g. HeuristicLab.Data).
    • Project names and their output are suffixed with their major and minor version number (e.g. HeuristicLab.Data-3.3, HeuristicLab.Data-3.3.dll).
    • Plugins can be structured hierarchically (e.g. HeuristicLab.Operators and HeuristicLab.Operators.Programmable).
    • Sub-namespaces can be used to structure the source files in a plugin.
    • Each plugin is represented by a component in Trac.
    • The leading string HeuristicLab. is omitted in Trac component names.
    • Data components that correspond to a property should have the same name as the property and are not prefixed by my (e.g. in Item filename is the correct name for the data component of the Filename property and not myFilename).

A source code example of well formatted HeuristicLab code is available here?.

2.4 Unit Tests

Unit Tests are to be included in a separate solution called HeuristicLab 3.3 Tests.sln. The project is organized into multiple folders corresponding to the namespaces.

The naming convention for unit tests is [Prefix] ClassName "Test" [MethodName] [CaseDescription]. ClassName can be descriptive and also describe a group of classes (e.g. DeepCloneables), it does not need to correspond to the actual class name. Examples:

  • DeepCloneablesTestClone
  • DeepCloneablesTestCloningConstructor
  • BinaryVectorSinglePointCrossoverTest
  • OnlineCalculatorsPearsonR2TestRandom
  • OnlineCalculatorsPearsonR2TestConstant

Each test can be categorized according to several dimensions:

  • Dimension 1 - via TestCategory attribute (required)
    • General
    • Algorithms.*
    • Encodings.*
    • Problems.*
    • Persistence
    • Samples.*
  • Dimension 2 via TestCategory attribute (optional)
    • Essential -> Tests are executed on the builder after each commit (should run reasonably fast)
  • Dimension 3 - via TestProperty("Time", "") attribute (required)
    • Short (ca. < 1s)
    • Medium (ca. < 10s)
    • Long (>= 10s)

2.5 Visual Studio Extensions & Addons

3. Versioning System

Source code and other documents are kept in the HeuristicLab Subversion repository available at https://src.heuristiclab.com/svn/core. Anonymous read-only access is enabled. If you want to contribute to HeuristicLab and therefore need write access to the repository, please write an e-mail to support@heuristiclab.com.

For an introduction to Subversion, please take a look at the free book Version Control with Subversion and the Online Documentation of the Subversion client TortoiseSVN.

3.1. Repository Layout

  • trunk
    • contains the main development branch (trunk)
    • documentation
      • contains all project documentation files (API documentation, license, presentations, etc.)
    • sources
      • contains solution files, scripts and applications required for building HeuristicLab
      • plugin folders
        • each HeuristicLab plugin has its own folder
        • the folder name has to be identical to the name of the plugin (e.g. HeuristicLab.Data)
        • each plugin folder contains sub-folders for each major and/or minor version of the plugin (e.g. 3.3)
  • branches
    • contains a folder for each development branch
    • there are three different kinds of branches:
      • feature/exploration branches
        • are used to develop new plugins or to explore and carry out major changes that effect large parts of the system
        • each developer is free to create new feature/exploration branches at any time
        • the name of a feature/exploration branch has to be descriptive
        • new plugins should be developed in a feature branch first
        • before merging a branch into the trunk, a comprehensive code review has to be done by at least one of the HeuristicLab architects
        • a developer who created a branch is responsible for deleting it again
      • release branches
        • are used to prepare release versions
        • are used to store old versions of plugins
        • the folder name of a release branch has to be identical to the major and minor version number (e.g. 3.1) (cf. Versioning)
  • tags
    • contain a folder for each HeuristicLab release bundle (tag)
    • it is not allowed to commit to tags
    • the folder name of a tag has to be identical to the whole version number (e.g. 3.1.0.304) (cf. Versioning)

3.2. Guidelines for Working with the HeuristicLab SVN Repository

  • all projects in the trunk have to be compilable in each revision
  • commit messages
    • each commit has to have a description (commit message)
    • WikiFormatting has to be used to format commit messages
    • each commit message must contain the ticket number of the corresponding Trac ticket (e.g. "(#1)")
  • repository content
    • the repository has to contain all files necessary for compiling HeuristicLab
    • automatically generated files (object files, assemblies, AssemblyInfo.cs, etc.) are not stored in the repository
    • resource files (*.resx) which are auto-generated for all forms and controls must be deleted from the project as well as from the repository if they contain no resource
    • files containing user specific settings are not stored in the repository (e.g. *.suo, *.user)
    • the SVN property svn:ignore has to be set to prevent that files are added accidentally (predefined property values for solution, project, and properties folders are attached to this page and can be imported)
  • branches and tags
    • each developer can create a new exploration branch at any time
    • new release branches for a plugin can be crated by the head developer of that plugin only
    • new tags are created by the head developer of HeuristicLab only

4. Versioning

All plugins and all release bundles of HeuristicLab have a version number following the schema Major.Minor.Build.Revision:

  • Major and Minor
    • in order to distinguish from older versions of HeuristicLab (1.1 and 2.0), all plugins of HeuristicLab 3.x should have a major version number greater or equal to 3
    • when incrementing the major version number of a plugin, the minor version number has to be set back to 0
    • the major and minor version numbers have to be included in the assembly name of each HeuristicLab assembly (e.g. HeuristicLab.Data-3.3.dll)
    • all major and minor versions of a plugin are kept in the repository and have to be functional in order to assure backwards compatibility
  • Build
    • the build number is used to identify different versions within the same major and minor version of a plugin
    • for each new version (major or minor version number increment), the build number has to be set back to 0
    • all builds within the same major and minor version are considered to be "functionally equivalent"
    • all builds within the same major and minor version have to be backwards compatible concerning data files
  • Revision
    • represents the last revision, in which the component (assembly) has been changed or in which a version has been released
    • when compiling assemblies the revision number is automatically extracted from the Subversion repository (cf. Automatic Extraction of the Current Revision Number)

4.1. Automatic Extraction of the Current Revision Number

The tool SubWCRev of TortoiseSVN is used to extract the revision number of the last change of a plugin. SubWCRev is executed by the command PreBuildEvent.cmd which has to be set as pre-build event in each project in the following way:

 cmd /c ""$(SolutionDir)PreBuildEvent.cmd" "$(ProjectDir).""

SubWCRev replaces the placeholders $WCREV$ and $WCNOW$ in the frame file AssemblyInfo.frame of the project and creates the file AssemblyInfo.cs.

5. Issue Tracking

The issue tracking system Trac is used to manage the HeuristicLab development process. The HeuristicLab Trac environment is available at https://sources.heuristiclab.com/trac/hl3/core. User credentials are identical to those of the Subversion repository. For anonymous access the user "anonymous" and an empty password can be used.

Further information about Trac can be found in the Trac User and Administration Guide.

5.1. Guidelines for Working with Trac

  • all development steps have to be represented by tickets
  • before working on a plugin, a ticket has to be created and accepted by the developer
  • each developer is allowed to assign tickets to other developers, if the ticket is in the responsibility of that developer
  • development progress has to be documented by ticket comments
  • for each commit associated with a ticket, a ticket comment has to be written that contains a link to the revision (e.g. "(r304)") and a short description (in combination with the link to the ticket in the commit message, this results in a bijective association of tickets and revisions)
  • each commit has to be associated with a single ticket
  • explanation of the information stored in each ticket:
    • Status
      • new and assigned
        • represent tickets that have just entered, but have not yet been picked up by a developer
        • if the ticket is assigned a release milestone (such as e.g. HeuristicLab 3.3.2) the ticket appears as "Waiting for completion", otherwise it is part of the backlog
        • each new ticket is assigned automatically to the developer of the corresponding component or manually to any other developer
      • accepted
        • tickets that are currently processed by a developer get the status accepted
        • the ticket status has to be set manually by the developer before starting to work on the ticket
        • if the ticket is assigned a release milestone, it appears under "Waiting for completion", otherwise it is "Under development"
      • reviewing
        • represents tickets of which the implemented work is being reviewed by another developer
        • A completed ticket should be reviewed by another member of the time to ensure that the work is of high quality and the implemented solution is in accordance with the standards set by the team
      • readytorelease
        • represents tickets that are release-ready, meaning that the work was implemented, tested, and reviewed
        • Tickets are only closed with "done" when a release is being made and remain open until the date of the release
      • closed
        • tickets which are resolved get the status closed
        • developers have to provide an explanation for closing a ticket
        • possible resolutions for closing a ticket are done (the issue was resolved and released), invalid (the issue described is not an issue), rejected (the issue will not be resolved), duplicate (another ticket has already been created for that issue), worksforme (the issue could not be reproduced), and obsolete (the issue is outdated and no longer relevant)
        • when a ticket is closed without being done, the developer has to provide a comprehensive explanation
      • reopened
        • the ability to reopen a ticket was removed
        • if an issue was previously closed, but still remains an issue a new ticket should be created referencing the other one
    • Type
      • defect
        • bug in a component
      • enhancement
        • improvement or extension of the existing functionality of a component
      • feature request
        • new component or new functionality of an existing component
      • task
        • other (administrative) tasks which are not associtated with programming directly (e.g. generating documentation, creating release branches, etc.)
    • Priority
      • the priority is used to rank the tickets in the backlog
      • the following priorities are available to classify tickets: highest (priority 1), high (priority 2), medium (priority 3), low (priority 4), lowest (priority 5)
      • classification of a ticket's priority has to be done by the user who reports the ticket
    • Milestone
      • a ticket has to be associated with a milestone
      • if the issue is targeted for release, it should be assigned a release milestone, otherwise the milestone HeuristicLab x.x.x should be chosen and it becomes part of the backlog
      • milestones represent iterations in the development of HeuristicLab
      • usually a milestone is associated with the version of a HeuristicLab release bundle
    • Component
      • a ticket has to be associated with a component (i.e. a plugin)
      • the name of a component has to be identical to the name of the namespace or the plugin of that component (the leading "HeuristicLab." is omitted)
      • if no component is suitable or if the component is unknown General should be used
    • Version
      • each ticket has to be associated with a version number of HeuristicLab
      • typically the ticket gets the version in which the described issue appeared
      • the version of the ticket will be changed once the resolution is set to done to reflect the version in which the issue was fixed
      • for exploration and prototyping, branches may be created and tickets may get the version branch indicating that the development is not affecting the trunk

6. Documentation

6.1. Wiki

The Trac wiki system is used for documenting the development of HeuristicLab. A description of the Trac wiki syntax is available at WikiFormatting.

6.2. Source Code

Source code is commented using single- or multi-line comments in English.

Additionally, each type (class, enum, struct, etc.) and each public or protected method, property, or variable has to be documented using a C# XML comment. These comments are used to generate the API documentated using the tools Sandcastle and Sandcastle Help File Builder. A description of XML comments and several examples can be found at XML Documentation Comments of the C# Programming Guide.

7. Best Practices

Check out the wiki page containing the [DevelopersBestPractices best practices].

8. Final Remarks

Use your brain!

Last modified 6 months ago Last modified on 08/16/16 17:31:59

Attachments (6)

Download all attachments as: .zip