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

Christian Kandeler christian.kandeler at digia.com
Tue Jul 9 12:50:47 CEST 2013


On 07/08/2013 09:01 PM, André Pönitz wrote:
> To recap, currently each plugin's code lives in a namespace FooPlugin, with
> non-exported parts further nested in an Internal namespace. The discussed
> changes are currently (a) drop the Internal namespace, and (b) lowercase
> the outer FooPlugin name to fooplugin.
>
> (a) Drop 'Internal'
> Pro:
>    - exporting classes currently involves not just adding the FOO_EXPORT
>      macro to the class itself, but also actually moving the code out of
>      the Internal namespace (mostly easy, "it's ok when it compiles")
>      including fixing all signal/slot use (no compile time check).
>    - removing means less typing in the future
>    - less line noise
>    - (marginal) saves a few bytes in symbols

The signal/slot thing is the only one that has any weight at all, in my 
opinion.

> Contra:
>    - It works as it is.
>    - Currently its easy to spot in the documentation whether something is
>      Internal (solvable)

This one is valuable, in my opinion. If you see in your code something 
like "FooPlugin::Internal::bar()" (or, even worse, "using namespace 
FooPlugin::Internal"), that acts nicely as a FIXME statement.

> (b) Lower case outermost namespace
> Pro:
>    - There's often not just the FooPlugin namespace but a likewise
>      named class. There are some corner cases where the causes (solvable)
>      trouble, but since namespace and class are different concepts, having
>      different naming conventions might "help"
>    - Other commonly used libraries have the "lowercase" convention for
>      namespaces (std::, boost::, llvm::)
>
> Contra:
>    - It works as it is.
>
>
> People I have talked to seem to be mostly on the fence on either issue
> (pretty much like I myself) so: Does anyone have a _strong_ opinion?

"Strong" would be an overstatement. A lackluster "Doesn't seem to be 
worth it" would summarize my feelings best.


Christian



More information about the Qt-creator mailing list