-
Notifications
You must be signed in to change notification settings - Fork 0
Guidelines
René Fonseca edited this page Jan 31, 2020
·
6 revisions
These guidelines apply to the Base Framework implementation and not third-party projects.
- Regardless of these guidelines the implementation MUST still be as compatible with third-party code as possible. Common issue is #define's with single word in third-party headers which may need to be #undef'ed.
- Do NOT include code copyrighted by other parties.
- Use 2 spaces for indents. Do NOT use TABs.
- Always include EOL at end of files.
- Stay below 120 chars for line length.
- Methods and variables use thisIsMyMethod/thisIsMyVariable style.
- Constants including enum values use upper case THIS_IS_MY_CONSTANT style.
- Classes and enums use ThisIsMyClass/ThisIsMyEnum style.
- Implementation is done in C++11 for high portability although later standards do have some nice features. Code MUST still be C++14 and C++17 compatible.
- Do NOT use new[] and delete[]. Use Allocator or similar classes instead if array is required. It is easy to add delete[]/delete mismatches.
- Use
_throw/_rethrow
instead ofthrow
to allow runtime hook of thrown exceptions. - Only throw types derived from
Exception
and always throw by value (not pointer). - Only catch exceptions as mutable. E.g.
catch (Exception& e) {}
. - Always initialize variables. Unless otherwise justified due to performance issues. Leave a comment in such cases.
- Avoid #define's and use enums whenever possible. Single word defines should be avoided completely to be naming clashes.
- In general all #define's use the long unique prefix COM_AZURE_DEV__BASE_. Only in special cases are we skipping the prefix.
- Use
#pragma once
to ensure single inclusion of header implementation. - Do NOT include headers not required. If a header is included by another header then do not include it explicitly.
- Do NOT include third-party headers; besides a few exceptions that cannot be avoided due to C++ standard requirements.
- A header should generally be accompanied with a corresponding source file to simplify diagnostic of compile errors.
- Add a unit test when a new feature is added. See
TEST_REGISTER
inbase/UnitTest.h
. - Third-party dependencies MUST be registered via
MODULE_REGISTER
inbase/Module.h
to allow automatic runtime detection of such dependencies.