[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Order of public, protected and private stuff in class declarations



Bjarke Hammersholt Roune wrote:

>IMHO it should be part of the coding convention that public stuff should be
>declared before protected stuff, and protected stuff before private stuff.
>This makes sense since most people will be looking for the public stuff,
>some people will look the the protected stuff and very few will look for the
>private stuff.

Perhaps as recommendation, but not as requirement. And IMHO as long as the
order is consistent for, say each library (PFile, PSound etc) the actual
order doesn't matter much.

BTW - I finally found out where I have the habit of writing privates first
from: I learnt my C++ basics with "C++ - The Complete Reference" by Herbert
Schildt (a bad book btw) which uses that order.

I guess I'll change the order in PFile someday. No priority though.

>IMHO methods should be declared before member variables.
>
>IMHO constructors should be declared before anything else, followed by the
>destructor.

That's all more or less implied by the "write readable code" thing.
We're in open source development, and that means
* People read the source and as the author of each piece of code is known
  people will associate him wigh the code. Nobody wants to have a reputation
  of writing ugly code.
* If people find a bug some of them really look at the sources and try to
  track that bug down themselves. Now if the code isn't readable enough
  they'll give up rather fast. So writing ugly code means getting worse bug
  reports and less testers.

Believe or not, this works surprisingly well ;)


	Christian
--

Drive A: not responding...Formatting C: instead