Namespaces, file names,...

Derek Atkins warlord at MIT.EDU
Mon Sep 8 12:17:13 EDT 2014


John Ralls <jralls at ceridwen.us> writes:

[snip]

> Since we want to make the API useful outside of GnuCash we should declare a namespace to wrap everything in, maybe Gnc. That way an application that wants to extend our Account class could still call their child class Account, like so:
>   class Account : public Gnc::Account;
> We'd stick
>   using namespace Gnc;
> in all of our implementation files so we don't have to write
>   Gnc::Account* acct = new Gnc::Account (book);
>
> So the question becomes:
> * Is Gnc OK for the namespace name?

Personally I prefer spelled out namespaces, so I would prefer "GnuCash"
instead of "Gnc" or "GNC".

> * Do we want to use camel-case or underscore-separated function and variable names?

My personal preference is CamelCase, where the first letter is capital
for types and classes, and the first letter is lower case for methods.

E.g.:

namespace GnuCash {
  class Account {
    setName(..);
  };
};

As for class members, I do not have a strong opinion about whether or
not to use m_<name>.

Nor do I specifically have a preference about getter/setter names.  I
definitely like setFoo(), but I don't know whether I prefer getFoo() or
foo() as the getter.  I think I have a slight preference to getFoo().

> N.B. The C++ code above mirrors the old C code to emphasize the different naming and calling conventions. The actual C++ code will be somewhat different.
>
> Regards,
> John Ralls

-derek

-- 
       Derek Atkins, SB '93 MIT EE, SM '95 MIT Media Laboratory
       Member, MIT Student Information Processing Board  (SIPB)
       URL: http://web.mit.edu/warlord/    PP-ASEL-IA     N1NWH
       warlord at MIT.EDU                        PGP key available


More information about the gnucash-devel mailing list