AUI Framework
master
Cross-platform module-based framework for developing C++20 desktop applications
|
AUI's code should be kept with the following code style:
No tabs
; only four spaces120
charactersCamelCase
. Every framework public API class name starts with capital 'A
'. Use GenericSpecific
pattern (EventClose
, not CloseEvent
, PacketConnect
, not ConnectPacket
). Using that convention files group nicely in file lists.lowerCamelCase
UPPER_SNAKE_CASE
m...
(lineNumber
-> mLineNumber
)...
(lineNumber
-> lineNumber()
, (field: mLineNumber
)set...
/with...
(lineNumber
-> setLineNumber(...)
, accessible
-> withAccessible(...)
)CamelCase
. Also used for stl-like functionality (AUI/Traits), in that case, snake_case
used for file names, struct name and its member functions.const
, noexcept
and [[nodiscard]]
whenever possibleUPPER_SNAKE_CASE
prefixed with 'AUI_
'. If the macro is intended to efficiently reduce code size (i.e. ui_thread
or async
) it's allowed to consciously name it using lower_snake_case
without prefix.#pragma once
instead of C-style include guards@
-style, not \
)A
', 'aui
', 'AUI_
' is a part of AUI's stable public API ready for the external usage. Symbols without such prefixes are called internal and can be also used (if possible) when needed. Be careful using internal symbols since there's no guarantee about their API stability.Basic example:
The whole AUI framework's code filled with assertion checks so if you do something wrong the framework will tell you about it. Also in AUI almost every assertion contains a quick tip how to solve the problem. It is recommended to you to do the same. For example:
The code above ensures that the function was not called from some other thread. As you can see, the tooltip is produced using extra brace pair and operator,
:
Do not put algorithm-necessary code inside assert()
since asserts are removed in release builds on some compilers, i.e. don't assert(("someAction failed!", someObject->someAction() != 0))
since it leads to hard-to-find bugs.
Assert is an enemy for the production application since it terminates program execution. Use it when it's condition relies only on the developer. Quick example:
It's hard to say which functionality can be called 'STL-like'. Commonly, any iterator-based algorithm (i.e. aui::binary_search
), global functions, trait structs are STL-like functionality. The final goal is to avoid mixed-style expressions like AString::const_iterator
which hurts the eyes.
Both C++ template instantiation mechanism and macro preprocessor are Turing complete. However, writing and understanding C++ template metaprogramming (TMP) and macro preprocessor code requires expert knowledge of C++ and a lot of time to understand. Use TMP deliberately.
Since TMP and macros often evolve custom syntax and usage scenarios, consider writing especially well documentation with examples when defining public API templates and macros.