S
Steve Folly
Hi,
I know (hope!) we all follow good practice here and name our source files
with the name of the class it defines. i.e. A.h defines class A, and A.cpp
defines the methods for class A.
Lately, I've been pondering the merits or otherwise of including the
namespace name in the file name as well. Our source code library is growing
in size at work, and a few libraries are starting to clash on names, and
getting the include paths right is tricky.
For example - say we have a class Factory in namespace GUI, and in a
different library, also a class Factory in namespace Database. One would
expect there to be 2 Factory.h files that could be found in the include path
- which one gets included would depend on the order the include paths. I've
started to sort out these clashes by renaming them GUIFactory.h and
DatabaseFactory.h.
Other similar situations include name clashes with standard library headers,
and clashes even within the same library (e.g. If GUI::Factory and
Database::Factory are in the same library).
I've avoided renaming existing files just for the hell of it, but I'm
thinking of using this style for all new files, even where there may be no
possibility of name clashes.
I know this might sound really petty, but it has highlighted these name
clash problems and I wondered if anyone here has some 'best practice' tips
for this sort of thing?
Thanks.
--
Regards,
Steve
"...which means he created the heaven and the earth... in the DARK! How good
is that?"
I know (hope!) we all follow good practice here and name our source files
with the name of the class it defines. i.e. A.h defines class A, and A.cpp
defines the methods for class A.
Lately, I've been pondering the merits or otherwise of including the
namespace name in the file name as well. Our source code library is growing
in size at work, and a few libraries are starting to clash on names, and
getting the include paths right is tricky.
For example - say we have a class Factory in namespace GUI, and in a
different library, also a class Factory in namespace Database. One would
expect there to be 2 Factory.h files that could be found in the include path
- which one gets included would depend on the order the include paths. I've
started to sort out these clashes by renaming them GUIFactory.h and
DatabaseFactory.h.
Other similar situations include name clashes with standard library headers,
and clashes even within the same library (e.g. If GUI::Factory and
Database::Factory are in the same library).
I've avoided renaming existing files just for the hell of it, but I'm
thinking of using this style for all new files, even where there may be no
possibility of name clashes.
I know this might sound really petty, but it has highlighted these name
clash problems and I wondered if anyone here has some 'best practice' tips
for this sort of thing?
Thanks.
--
Regards,
Steve
"...which means he created the heaven and the earth... in the DARK! How good
is that?"