Palomino - Coding

©2004,2008  Jim E. Brooks   http://www.palomino3d.org


Contents


Overview of Coding

[2007/12]

Source code is written in C++. For portability, the code is written to abstract the graphics system and scene graph. Generalized C++ classes and Facade classes are used. For example, the Graph class is a Facade over an osg::Switch node.

To catch memory corruption or uninitialized data, critical classes have a "type signature" data member which is checked in DEBUG builds.


Coding Style

[2004,2008/04]

Naming convention:


Lua Coding Style

[2008/06]

See scripts/module.txt.


Globals vs. Singletons

[2007/06]

Globals are either defined as members of a Global class in each library, or as Singletons. Both have advantages and disadvantages.

As members of a Global class, globals become obvious and are easy to search. They're accessed by writing "global.mMember". The order of construction is the order they're declared in the class. And, they auto-destruct in inverse order at program exit. A disadvantage is that this order is limited to the scope of the class.

Singletons solve the problem of globals (or static objects) depending on other globals. Disadvantages are that Singletons don't auto-destruct as Global members do, and Singletons are difficult to find when searching for globals (for the purpose of implementing threading).

global::mWorld.GetEdge();  // obvious global
World::GetEdge();          // hidden global

Reminders

[2004,2008/04]

Do

Don't


Last modified: Mon Jun 16 23:31:10 EDT 2008