[Qt-creator] Use of namespaces in Qt Creator's own code

Ziller Eike Eike.Ziller at digia.com
Tue Jul 9 15:50:06 CEST 2013


On 09.07.2013, at 13:35, Oswald Buddenhagen <oswald.buddenhagen at digia.com> wrote:

> On Tue, Jul 09, 2013 at 12:51:51PM +0200, Ziller Eike wrote:
>> 
>> On 09.07.2013, at 11:11, Oswald Buddenhagen <oswald.buddenhagen at digia.com> wrote:
>> 
>>> On Mon, Jul 08, 2013 at 09:01:56PM +0200, André Pönitz wrote:
>>>> (b) Lower case outermost namespace
>>>> Contra:
>>>> - It works as it is.
>>>> 
>>> - it's non-qt
>> 
>> I don't see the point, Qt doesn't use namespaces at all. So going the Qt way would be to remove all namespacing...
>> 
> orly?
> namespace Ui (any uic-generated file)
> namespace QtPrivate (lots of internals, obviously)
> namespace QDBus
> namespace QTest
> namespace QtConcurrent
> namespace QPatternist
> 
> i got bored at this point …

Ok, there are. They are just not widely used. So the requirement that "components" in Qt Creator are in a namespace is already non-Qt. I don't see a problem with deviating from Qt's "convention" in that case, which doesn't seem to be used very consistently in Qt either (e.g. QtPrivate seems to be only used in QtConcurrent and QtCore at all, all others don't seem to namespace their private API)

>>> to solve the clash problem, there are two approaches:
>>> - use an additional convention (ugly)
>>> - FooNames::Foo
>>> - Foo::FooClass
>>> - remove the redundancy
>>> - Foo::Plugin
>> 
>> The clash is with things like CppEditor::CppEditor.
>> 
> maybe the problem is the namespace name then?
> the vcs plugins don't have any suffix. maybe the same should be done for
> the laguage plugins.

CppEditor is not one of the language plugins, that is CppTools. CppEditor is really the plugin that contains only all the editor related code.
Similar with BinEditor::BinEditor, DiffEditor::DiffEditor.

> or, because the namespace belongs to the plugin, name it
> CppEditorPlugin. of course this would then produce
> CppEditorPlugin::Plugin …

That would lead to all namespaces having the redundant "Plugin" postfix.

> yet another option would be "big endian" notation for the plugin names:
> EditorCpp, VcsGit, ProjectManagerQmake, etc. a bit unnatural, but sorts
> nicely (easier to catch omissions during refactoring), and is profoundly
> distinct from the class naming convention.

I just don't know why to go through hoops instead of just going for lowercase namespaces. These would also be visually profoundly distinct from the class naming.
It looks to me like the only "contra" against lowercase namespaces that we are currently talking about is "it's non-qt" which I find arguable.

-- 
Eike Ziller, Senior Software Engineer - Digia, Qt
 
Digia Germany GmbH, Rudower Chaussee 13, D-12489 Berlin
Geschäftsführer: Mika Pälsi, Juha Varelius, Anja Wasenius
Sitz der Gesellschaft: Berlin, Registergericht: Amtsgericht Charlottenburg, HRB 144331 B




More information about the Qt-creator mailing list