[kplato] Re: koffice/kplato
Raphael Langerhorst
raphael-langerhorst at gmx.at
Mon Nov 1 11:35:58 CET 2004
On Monday 01 November 2004 08:11, Bo Thorsen wrote:
> On Saturday 30 October 2004 19:02, Raphael Langerhorst wrote:
> > CVS commit by raphael:
> >
> > Updated the copyright year to 2004 in about data,
> > added information in the tODO file how to grep FIXME and TODO
> > items from source files, added entry about namespaces (still to
> > discuss on mailinglist) in TODO file.
> > [snip]
> > +- Use KPlato namespace for all KPlato classes
>
> Why would you want to use a namespace for application code? It
> doesn't help.
>
> Bo.
Ok, this is something we still need to discuss: namespaces. I'll start
with a reference to koffice/kspread/DESIGN.html:
When creating a new class, use namespace KSpread. Legacy code will be
someday converted into namespaces but in the mean time do not use
KSpread prefix anymore. Example: use KSpread::Foo instead of
KSpreadFoo. Also source file name should not contain kspread prefix
anymore, i.e. foo.h and foo.cc (but not kspread_foo.h and
kspread_foo.cc) for the above example.
The project I'm mainly working on (G System) also uses namespaces for
every part of the Project. As gcc now supports namespaces I think
it's acceptable to think of a good/clean source code structure. Using
namespaces results in a better structured code IMHO. It's a bit like
designing tables for databases (ER diagrams). You don't want a column
that let's you enter a name like "Raphael Langerhorst", but normally
you want two columns, one for your first name, the other for your
last name, this allows for better data handling. It's quite the same
with sourcecode. If we're naming classes KPTProject for example then
we could also call it KOKPTProject (KOffice KPlato Project). Of
course we do not use the KOffice prefix as well (but it should show
the issue). It would be better to use sth. like KPlato::Project, then
it's clear that it is the project class of kplato and it is possible
to distuingish between class type (Project) and where it belongs to
(the KPlato software or namespace). That's like distuingishing
between first and last name of a person ("Raphael" and
"Langerhorst").
I guess at the moment the benefits are not so clearly visible, but in
the long term using namespaces results in better code reusability and
management, especially in large projects.
What do you think?
Raphael
--
G System, The Evolving Universe - http://www.g-system.at
More information about the kplato
mailing list