Namespaces, file names,...

Christian Stimming christian at
Mon Sep 8 14:22:45 EDT 2014

Am Sonntag, 7. September 2014, 15:10:13 schrieb John Ralls:
> > I strongly prefer namespaces in all-lowercase. I have somewhat a
> > preference
> > for "gnc" as namespace name, but we are an application anyway and not a
> > library, so we're basically free to choose whatever we want as interface
> > naming schemes.
> Any particular reason for the all lowercase preference? Not that it matters,
> gnucash and GnuCash are equally unique.

I think one relationship wasn't mentioned so far: The filenames and the 
corresponding namespace and class names. I think both should be as identical 
as possible - similar to Qt, different from glib.

Namespaces in lowercase gives also directory names in lowercase. Class names, 
well, should appear in the file names IMHO as unchanged as possible. I prefer 
both with the first letter in capital, but I know this causes occasionally 
some hassles on windows systems, as those colleagues notoriously forget to add 
their include directives with the correct case sensitivity. Other people argue 
that file names should be all lowercase in general. Both views exist.

> I don't mind tagging member variables, and I find m_varName to be clearer
> than just sticking an underscore at the end. One can go one step further
> and tag static members with a c_ or an s_, while being aware that static
> members, just like any other static or global variable, require extra
> synchronization and so should be avoided as much as possible.

Ok for the prefix. However, "static class members" are not at all evil. 
They're a normal part of the language and needed for modelling certain aspects 
of a program. What is evil are global variables. But static class variables 
are just fine - they are fixed into their scope and have access rules. They 
are simply needed occasionally. Nothing that necessarily has to be avoided.

> Only Mike has expressed a strong preference for camel, with everyone else
> not seeming to care much. So let's go with camel, with Typenames (classes,
> structs, enums, and POD aliases) having the first word capitalized and
> function and variable names having the first word lower case. Functions
> with 'C' linkage (i.e. legacy wrappers for keeping the rest of GnuCash
> working) will be snake or start with xacc.
> Macros, and only macros, will be all caps.
> Let's also have the following conventions for "special" variable names:
> * Member variables begin with m_
> * Static member variables begin with c_ (for class)
> * static constants begin with k_ (and should always be used instead of
> macros) * static variables in the anonymous namespace (a.k.a. file scope)
> begin with s_ and require a detailed comment about why such a thing is the
> only feasible way to implement whatever-it-is.

Ok with me.



More information about the gnucash-devel mailing list