Header files (Re: A little review of kdecore & kdeui)

Frans Englich frans.englich at telia.com
Sat Apr 8 16:01:17 BST 2006


On Saturday 08 April 2006 14:04, Cristian Tibirna wrote:
> On 8 April 2006 09:13, Aaron J. Seigo wrote:
> > On Saturday 08 April 2006 03:10, André Wöbbeking wrote:
> > > Is it really easier?
> >
> > after working with Qt4 for a while now, my experience says "yes, it's
> > easier, though only marginally".
> >
> > you just #include <ClassName>, exactly as you type it when doing "new
> > ClassName". no more having to remember which header contains the class
> > (think qlayout.h) and makes it rather obvious what classes are being used
> > in the file.
>
> ACK. At my work we have a hard rule that says: one class per compilation
> module and filename == classname. This saved our collective arse many a
> time when refactoring the >2m LOC. It all just so much simplifies things,
> thanks to "the rule of least surprise".

Exactly. I use that principle a lot as well. Can't nothing but wholeheartedly 
recommend it. Of course, the size of the win scales with the size of the code 
base.

That's also why I vote for file name == class name, and forward headers 
because it simplifies so much; as clearly outlined by Cornelius' recent 
mails.

However, in some cases it really makes sense to put two or more classes in one 
file, because the classes are local, very small helper classes. In those 
cases I have the thumb rule that the following must be reached: 1) the file 
name *must* somehow reflect that it contains a "collection"; and 2) the file 
*must* have a @file Doxygen tag which explains what it contains(since it's 
very difficult at best to figure it out). When those measures are taken, I 
think it justifies those rare cases(which should be nothing but very rare) 
where multiple classes in one file makes sense.


Cheers,

		Frans




More information about the kde-core-devel mailing list