Open antsouchlos opened 2 years ago
My thoughts:
See below
We previously agreed on using snake case
for API and user-facing functions and classes and CamelCase
+prefixes for internal classes and functions. In my es2_renderer branch i have already rewritten the nre::gpu::...
functions to fit this style.
On the other hand, maybe having different conventions and prefixes is confusing, but i don't think oe::TaskManager
or oe::sdl::WindowSystem
for example looks well at all.
I could maybe consider snake_case
for everything though (classes included), if we are to keep one convention and remove prefixes, like this:
oe::task_manager
,
oe::sdl::window_system
Same as above.
A better thing in my view would be to suffix with _
, like
namespace oe{
class some_class {
private:
int some_integer_;
std::array<char, 256> buffer_;
};
};
This already exists to some degree in the code and this also makes special syntax highlighting by text editors (particularly the one i am using, Kate) possible, while with m_
, it doesn't.
No objections or anything particular to the _t
and t_
, but for functions same as above.
Snake Case for everything it is then
I also don't see any issues with using _
as a suffix instead of m_
as a prefix for member variables.
A rewrite to snake_case
can only happen AFTER i have finished with the feature/es2_renderer
branch though. Keep that in mind.
I don't think that a basic ES 2 renderer is far off though, i have almost finished rewriting the shaders and will only need to rewrite adapt the renderer
now.
No worries, let's just find some convention first. The rewriting of the code to fit the agreed upon convention can follow at a later stage, when it is practical.
But I take it we have agreed on the first proposed convention, with the following changes?
CamelCase
, everything snake_case
_
-suffix instead of m_
-prefix for member variablesYes exactly. Those and no prefixes, everything in namespaces. I strongly object your supposed way of formatting namespaces though (in the other issue).
Reopening until changes are implemented
Actually, having snake_case
for class names, function names and variables might be a bit confusing.
One Idea would be to change the convention for class names to snake_case
with a _t
suffix.
Since this would clash with the template parameter naming convention, however, here is a new proposal for that one:
CamelCase
for template parameters. If they are class template parameters, add a _
-suffix to indicate they belong to a class:
template<typename Arg_, int NonTypePar_>
class some_class_t {
public:
some_class_t() = default;
template<typename FuncArg, int FuncNontTypePar>
void do_smth() {}
};
Yes, now it makes more sense. Also names ending in _t
are highlighted differently in my text editor.
Please update the wiki with the new naming conventions for classes and template parameters we agreed on
Done
I think it is long overdue to agree on some common conventions for OxygenEngine.
I'll start with proposing a convention for identifiers, even though I am sure @philsegeler won't be happy with everything. At least we will have a base upon which to start a discussion.
Proposed naming conventions
General
No function or class name should ever be prefixed with e.g.
oe_
,csl_
, etc. Instead simply use namespaces. And never ever start any identifier with an underscore.Functions
Function names should be written in
snake_case
. This applies to both free and member functions:Classes
All class names should be written in
CamelCase
:Member variables
Member variables should be prefixed with
m_
to signal they are class members, not local variablesTemplate parameters
There is no distinction between class and function template names.
All template parameter names should be written in
snake_case
. Type template parameters should be suffixed with_t
, non-type template parameters should be prefixed witht_
: