I'm working on a project and I came to the following naming problem.
I'd like to implement the factory pattern but I don't know the best class namings to use (i'm changing from one to the other and it's quite time-consuming :S).
I usually go for namespaces to separate groups of classes, but my problem is with this specific piece of code:
class Mesh
{
...
};
namespace Factory
{
class Mesh
{
...
};
}
...
Factory::Mesh meshFactory;
Mesh *mesh = meshFactory.create(...);
My problem is that if I use this structure I can mix up the Mesh classes (whether is the factory class or the actual Mesh class). Actually, this is a simplification, my problem involves some more namespaces and the classes that have the same name are used in both namespaces.
I was thinking on maybe using suffixes to separate the classes and put them on the same namespace, for instance:
class Mesh
{
...
};
class MeshFactory
{
...
};
MeshFactory meshFactory;
Mesh *mesh = meshFactory.create(...);
So there's no confusion on what each class do.
I don't like the simple solution which is to use different namespaces and invent different names, because I would end up using the namespace name do differentiate them:
class Mesh
{
...
};
namespace Factory
{
class MeshFactory // I can't figure a better different name
{
...
};
}
I prefer the second option.
Is there a solid reason why is better the first option? Or is there another way? What does best-practices say about this?