Menu

Code_Style_Conventions

Shane Saxon

[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 visualization, 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:
- Keep width to 80 characters, (exceptions okay when necessary or practical.)
- 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.

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.
- 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 the nptypes.h file.
- Use the prefix 'kNP' followed by a lower-case name


Related

Wiki: Cross_Platform_Guide
Wiki: Developer_Guide
Wiki: Home