Skip to content

Code Style Guidelines

Shane Saxon edited this page Dec 3, 2015 · 10 revisions

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 CC0 Public Domain declaration at the top.
  • Keep width to 77 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.

Data File & DB Conventions:

  • All data files should have the prefix 'ANTz...csv/xml/etc'
  • CSV files should be directly compatible with DB tables.
  • Field names in the first row identify the table and fields, 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')

--- 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

Clone this wiki locally