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

André Pönitz andre.poenitz at mathematik.tu-chemnitz.de
Mon Jul 8 21:01:56 CEST 2013


Hi all (developers)

There's now a "master bug" for cleanup related issues for the 3.0 cycle
at https://bugreports.qt-project.org/browse/QTCREATORBUG-9761.

One discussion that arose in the context was whether we should continue
the current use of namespaces in Creator code, or whether there should be
some tweaks, or not. There are two proposed modifications, both with little
real impact.

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

Contra:
  - It works as it is.
  - Currently its easy to spot in the documentation whether something is
    Internal (solvable)
  - boost has a similar setup with its 'details' namespace
 

(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?

Andre'



More information about the Qt-creator mailing list