[RFC] Solid and use of namespaces

Hans Meine hans_meine at gmx.net
Tue May 23 16:33:59 BST 2006


On Sunday 21 May 2006 13:18, Krzysztof Lichota wrote:
> Definitely "PowerManager". Using generic names ("Manager") makes it
> harder to grep for name, replace it with other, find it using filtering
> by class names, etc.

AFAICS, one can combine the advantages of namespaces (grouping together what 
belongs together) with the advantage of grep'ability by just sticking to

// only use Solid::Power here if your whole .cpp is about Power stuff:
using namespace Solid;
Power::Manager man;
man.foo();
...

Yes, I see that this could break _all.cpps.

Note that it's also possible to create special namespaces for "using" them:

namespace PowerNS
{
  typedef Power::Battery Battery;
  typedef Power::UPS UPS;
  ...

  // prefix only the too general term(s):
  typedef Power::Manager PowerManager;
};

ALAS, this introduces slight redundancies, especially with enum values etc.

Ciao, /  /
     /--/
    /  / ANS




More information about the kde-core-devel mailing list