KDE 4 namespaces

Cornelius Schumacher schumacher at kde.org
Mon May 9 01:42:19 BST 2005

On Monday 09 May 2005 01:57, Thiago Macieira wrote:
> with KDE 4 porting now imminent, I thought it was time to start the
> discussion on namespaces. If you've talked to me recently on the
> subject, you know I am pro-namespaces and would like to see
> everything deeply namespaced.
> I know there are those who feel differently. Please voice your
> opinions.

I'm against changing our namespaces. Your proposal would mean to change 
the names of every single class in KDE. This would mean a huge load of 
work and be a source of tremendous confusion. With little gain, I have 
to add.

Note that we already use namespaces for all library classes. Most of 
them use the K prefix as namespace, some libraries use their own C++ 
namespaces. This might not be the optimum solution, if you would now 
start to write KDE from scratch, but given the tons of code which are 
based on the current namespacing it's good enough.

Also note that Qt 4 hasn't hasn't changed it's namespaces. That's 
another indication that there are good reasons for not doing it.

> The main drivers for using namespaces are:
> - better organisation of our classes
> - better mapping of classes to libraries
> - benefitting from Qt4's split libraries (Core, Network, UI)
> - less namespace pollution, leading to less chance of symbol
> duplication

None of this requires the use of other namespaces than the ones we 
currently have. I really fail to see what benefits the changing of the 
namespaces would have.

> Namespace KDE::AddressBook
> --------------------------
> Uses: KDE::UI
> This namespace contains the addressbook-related classes, currently in
> libkab and libkabc.
> Questions:
> - why are there two libraries?

libkab is obsolete and only needed to convert KDE 2 addressbooks to the 
current format.

> - personally, I would prefer KDE::Utils::AddressBook

So, if I want to use the standard addressbook I have to write 
"KDE::Utils::AddressBook::StdAddressBook *ab = 
KDE::Utils::AddressBook::StdAddressBook::self();" or generously add 
"using" directives? That's a nightmare.

Cornelius Schumacher <schumacher at kde.org>

More information about the kde-core-devel mailing list