7
In Java and Actionscript3.0 we use namespaces based by directory path, I see much use of namespace, but are not based on the "location" path of the class in the folder.
I searched a lot if there was any kind of organization like that has that "recommendation" for PHP, the PSR-4, but for C++ I found no recommendation, I know it must be something trivial, but I believe a minimum of organization, regardless of the size of the team or being a personal project can be a good way, in case the purpose is not to use namespaces in all classes, only in isolated libs that I will reuse for various applications.
There is something like this for C++, an "official design standard"?
Since it doesn’t exist, I thought I’d do something like this:
./fornecedor/categoria/foo.hnamespace Fornecedor { namespace Categoria { class Foo() { public: Foo(); }; }; };./fornecedor/categoria/foo.cpp#include "foo.h" using namespace Fornecedor::Categoria; Foo::Foo() { ... }
In this example above:
- Class name is associated with file name
- Files and folders are always in lowercase (lower case letters)
- Category would be only to divide the use of classes, for example
fornecedor/matematica/soma.cppandfornecedor/matematica/divisao.cpp
This is just an idea, it would be a good way?
Did the answer resolve what was in doubt? Do you need something else to be improved? Do you think it is possible to accept it now?
– Maniero