Boost logo

Boost :

From: Miki Jovanovic (miki_at_[hidden])
Date: 2000-02-23 11:41:43


"mark borgerding" <mborgerdin-_at_[hidden]> wrote:

Well, most of you point were well taken, but maybe too strongly.
Following your thinking, noncopyable is also not a good idea, and I
most definitely do not agree with you.

> 2) There might be a temptation to add functionality into this base
> class.
> It would be an all-too-convenient place to dump some functionality
that
> someone on a team decided that every class needed. I was on a project
> that had a common base class (a la MFC's COBject). It was a mess.
> Eventually the base class became pretty bloated with code for
> archiving, logging, synchronization and other things that many classes
> did not need.

Adding functionality to abc is a strict no-no. My hope was to get abc
into a 'system' header file which is out of bounds for change.

> 3) Learning curve
> The first time I see " : public virtual_destructor " in code I will
> need to go take a look at the class. That is lost time. The fact
that
> it requires another file is a possible configuration problem. These
> are small problems, but there is little or nothing gained to offset
> these dangers.
> Good developers have already been conditioned to look for virtual
> destructors in a polymorphic base class. If a subclass is used for
that
> purpose instead, there is an associated learning curve, albeit
trivial.
> Inexperienced developers that may not know to look for the virtual
> destructor will also not know to look for the inheritance. And if
> there is a choice between learning one of the two methods, I think
> anyone would agree that the beginner should learn the standard means.

Well this is exactly what burned me and my friends several times. A
simple thing like:

class ICommand {
  public:
    virtual void execute() = 0;
};

and I have introduced a death trap in my code. I would have to add:

  public:
    virtual ~ICommand() {}

to make it safe. And for this reason I found abc much cleaner:

class ICommand : abc {
  public:
    virtual void execute() = 0;
};

Im my opinion having the virtual destructor in this interface actually
decreases readibility, and abc looks better. Of course this is just my
opinion. That is why I asked for opinions.

Cheers,

Miki Jovanovic.


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