On 03/06/2010 12:01 PM, Poldie wrote:
I was just wondering what the erudite folks reading this group would
recommend as an example of a clean, well designed and coded C++
application. I'm particularly interested in the way classes are
composed, and I'm also fairly interested in exception handling. All C+
+ books are full of examples of cars and cats but these seem to be
idealized examples, and I'm interested in real work examples. Perhaps
there are some open source projects which are readily obtainable which
someone here can give me a pointer to.
IMHO regardless of how good the code works, if it is not documented it
will potentially become unmaintainable. In light of this I recommend you
look at Doxygen which can generate code documentation from the code and
specialised comments.
IMHO I'd recommend using object orientation, which in simple terms means
creating classes to provide a black box function with well defined
interfaces. Code format style is not so important as code beautifiers
can reformat as required, (I use uncrustify).
IMHO you should keep all functions, or functional blocks to less than 2
pages, (~50 lines), for ease of understanding. Also your code should
attempt to catch any exceptions as close to the point of occurrence as
reasonable thus reducing the time determining their source if they do
occur. Lastly, you should pay special attention to constructors and
destructors of classes that allocate/free/share memory. These problems
can be difficult to debug, so be clear as to when they go in and out of
scope, and which are responsible for allocated memory! On that note, do
use the STL libraries which will save you a lot of time.
Regards
JB
lines for a function. Functional decomposition is good yes but specifying
irrational.