Coding Guidelines - mgsystemsllc/chss_prototype GitHub Wiki

Introduction

This document defines the coding style to be used in the CHSS prototype project. The style are standard but have been listed here for better dispersal among team members.

Naming Conventions

  • Function, variable or object names composed of a single word should be in lower case only. e.g gender
  • Function, variable or object names composed of more than one word should be in camel case i.e. they should start with lower case and every subsequent word should start with a capital letter. E.g dataId
  • Check for use of singular or plural words in names of variables, functions or objects. e.g if a function processes a single object, the function name preferred should be processObject(), whereas a function processing multiple objects should be named processObjects().
  • No underscore or hyphen to be used in naming conventions
  • Complete words to be used in names instead of short abbreviations

Code File Organization

  • The variables used across the file should be declared at top of file. First private variables and then public variables.
  • The variables to be used across specific functions to be declared on top of function definition.
  • Definition of member functions of a single object should be grouped together in a file.
  • Private member functions to be defined first, followed by public member functions.
  • The main calling function of the file should be defined at the bottom of the file.
  • The code file should have well demarcated sections marked with comment

Comment Formats

The code should have enough comments to understand the flow and logic coded. The different types of comments to be used in the code file are:

  • Generic Comments

      /**
      * <Content>
      * 
      */
    
  • Comments in front of code

      var variable; /**< <Detailed description after the variable> */
    
  • Comments for objects

      /**
       * @object <object name> <description>.
       */
    
⚠️ **GitHub.com Fallback** ⚠️