Code Style Guidelines - openantz/antz GitHub Wiki

Home - Cross_Platform_Guide - hosted at openANTz.com

ANTz is currently a stand-alone app. However, we plan to make it into an API library that can be bolted into other programs such as data analytics, CAD, 3D modeling, network management, gaming and entertainment (film & video.)

We are significantly dependent on the OpenGL library and borrow some conventions from SGI as well as conventions used in DB processing.

In general we try and keep the code in a consistent style to help with readability and maintainability.

Code Conventions:

  • All files part of the core code ('sdk/src/' folder) must have the LICENSE declaration at the top.
  • Use Doxygen comments (function definitions and constants).
  • Add your initials where changing code (ie: //zz).
  • Keep width to 80 characters, (exceptions okay when necessary or practical.)
  • Include headers should use double quotes unless its a standard library,
    ie: #include "curl.h" VS <stdio.h>
  • Declare global headers at top of the '.h' file.
  • Declare local headers at top of the '.c' file.
  • Declare local function prototypes at top of '.c' file.
  • Declare all variables before any code logic and init to 0 or NULL.
  • Keep names short and descriptive, describe details using comments where declared.
  • All code files should be lower case and have the prefix 'np'.
  • Functions in header files should also have prefix 'np' ie: 'npMyFunction()'.
  • Variables start with lower case and use upper case for new words 'myVariable'.
  • Constants prefix is 'kNP..' then start with lower-case, ie: 'kNPgraphPause'.
  • Check malloc errors for out of memory.
  • Released code should include a compiled release application binary.
  • Project should be stripped of all miscellaneous files that are not required to build.
  • Project should build both Release and Debug versions without warnings.
  • All files should have at least two empty line returns at the end of the file.

File & DB Conventions:

  • File names use 'antz' prefix followed by table type then the file extension, ie: antztags.csv
  • Database tables use 'np' prefix, ie: np_node_id
  • CSV files should be directly compatible with DB tables.
  • First row identifies the table type and field names, ie: 'np_node_id,type,etc...'
  • Data records each row after that. See wikipedia for CSV standards...
  • Field names should be of form 'rotate_rate_x' (in C this is 'rotateRate.x')
  • In addition to the globals, each user dataset has its own directory structure.

--- below are additional details under construction ---

Functions:

  • External visible API functions precede with 'np' followed by an optional lower case abbreviation for the file or category. In example nposFileDialog()

Variables:

Constants:

  • We often use defined constants in place of variables.
  • Most constants should be placed in the nptypes.h file or similar, ie: npdbtypes.h
  • Use the prefix 'kNP' followed by a mixed case 'variable style' name, ie: kNPexampleConstant
⚠️ **GitHub.com Fallback** ⚠️