Skip to content

BestPractices

djewsbury edited this page Feb 5, 2015 · 7 revisions

#Best Practices

This sections contains best practices and style rules used within XLE.

#Contents

Page Description
Naming Conventions Guidelines for naming identifiers
Order Of Interest Rule Writing good class definitions
Writing Effective Comments Writing comments in XLE
Meaningful Naming Guidelines for inventing meaningful names
Smart rvalue references Guidelines for use of rvalue references and move operations
Virtual Destructors Class with virtual methods should have a virtual destructor
Move Constructors Never Throw Move operators and constructors should be marked never_throw
Exceptions And Constructors Rules for exceptions thrown from constructors
Explicit Literal Types Be explicit about types of literals
Insulation in C++ Insulation of implementation details
Smart ptrs & functions Use of smart pointers for function parameters and return types
RAII Resource Allocation Is Initialisation principle
Self-Sufficient Headers Practices for headers and #include statements

#Outline

It's recommended that all code in XLE follows these practices as much as possible.

However, that said, all rules are made to be broken. Many practices have their exceptions, and there are always situations where the only practical solution is a special-case solution.

But. This is important -- if you choose not to follow the best practices outlined here, then you should have a good reason for it, and you should know what you're doing. If you have some doubt about your decisions, then just following the practices is best.

Every practice is provided with details and rationale detailing the intentions behind it.

Every practice beings with "Consider," "Prefer," or "Always". Hopeful the intention there is clear. While all good practices are important, the ones that are marked "always" tend to have further-reaching effects.