C++ Tips: Difference between revisions

Jump to navigation Jump to search
860 bytes added ,  7 October 2009
no edit summary
No edit summary
Line 4: Line 4:


* Use the SimGear primitive types for quaternions, vectors and matrices - the PLIB ones are deprecated (and PLIB will be removed at some point in the future). In some places it makes sense to use OSG types directly - that decision is left to the developer to decide which makes more sense.  
* Use the SimGear primitive types for quaternions, vectors and matrices - the PLIB ones are deprecated (and PLIB will be removed at some point in the future). In some places it makes sense to use OSG types directly - that decision is left to the developer to decide which makes more sense.  
== Formatting and Style ==
Note FlightGear is full of different code styles and formats - the best guidance is to follow the code you're working in, unless it is obviously broken.
* Prefer early-return style. Don't make people scroll to see which code-path they're inside; use <tt>return</tt> to manage control flow, instead of deep nesting of <tt>if</tt> clauses. If you are nesting more than three level deep, consider making a helper function for the inner levels, or see if you can invert the logic to reduce indentation.
* Use exceptions. Exception support is not well developed, but they provide a clean way to handle genuinely unusual situations without (easily ignorable) bool or integer return codes. The main loop catches exceptions, so use the SimGear exception, provide good location and message strings when you throw, and all should be well.


== Standards ==
== Standards ==
580

edits

Navigation menu