Boost logo

Boost :

From: Thomas Matelich (toms-mailing-lists_at_[hidden])
Date: 2001-08-09 16:52:42


Daryle Walker wrote:

> on 8/8/01 11:31 AM, Thomas Matelich at toms-mailing-lists_at_[hidden] wrote:
>
> > On the other hand, a lot of programmers out there haven't read the GoF book
> > and don't chase down pattern literature. I may be wrong, but I think Boost is
> > opening some people eyes to the power of STL and some of the really cool
> > things you can do with C++. So I'm in favor of finding a place in Boost for
> > documenting C++ patterns/idioms, with frameworks *and* descriptions of how to
> > do it by hand. To the user who hates writing 4 line classes, instantiating a
> > template seems ok, and the framework provides a reference implementation which
> > documents the gotchas to be aware of.
>
> What's the GoF book? (I guess I'm one of the programmers that hasn't read
> it.)

Bill Kempf answered this but I was just using it as an example of semi-advanced OO or
C++ concepts. Great book.

> It is not just about not liking to write 4-line classes; it's when you have
> to do it a lot of times. Why have a whole bunch of manual classes lying
> around?

Good point, of course.

> > So I guess my vote would be that I am in favor of finding a place in Boost for
> > this library, but I don't necessarily think that place is in utility.
>
> I think the base-from-member classes are like boost::noncopyable. That
> class isn't technically needed either, since the developer could manually
> declare a copy constructor and an assignment operator without defining them.
> These classes help show intent, and only one place to debug problems.

I think I need to add the comment that I think you implemented this idiom very well.
I think for the user new to the idiom the tradeoff between using the name and having a
typedef plus the scoping syntax is a good one. But, once the knowledge hurdle has
been leapt, I (personally) would probably switch to writing it by hand. I think the
comparison to noncopyable is a stretch because the only user overhead is an include
and putting in private inheritance.

The argument about debugging problems is a good one, I think the DRY (Don't Repeat
Yourself) principle is great. I've never used this, so I would have to ask, have you
ever messed it up writing it by hand (besides general syntax errors), how is it
possible? Weigh that against copy and paste errors where you forget to increment the
UniqueID, and the various typedefs.

How about a conditional boost inclusion? Officially recommend it and if people say
they are using it after X months, make it official.

--
Thomas O Matelich
Senior Software Designer
Zetec, Inc.
matelich_at_[hidden]
tmatelich_at_[hidden]

Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk