Re: [libxml++] Document interface



On Fri, Sep 26, 2003 at 03:28:01PM +0200, Murray Cumming Comneon com wrote:

> > From: Christophe de VIENNE [mailto:cdevienne alphacent com] 
> > While working on Document, I was wondering why the 
> > write_to_xxx functions are 
> > virtual.
> 
> Probably because I make methods virtual by default, because I don't pretend
> to know who needs to subclass and override.

But then it can be argued that because all (or most) methods are virtual
the users don't know what can, or should be, overridden.

There can be advantages to limiting the points of customisation, but
probably not until the API is complete and stable.
So I guess I'll shut up about that.

I agree with making the public functions non-virtual and only having the
implementation function virtual. I think Sutter argues for this, on the
grounds that write_to_stream should be consistent and always forward to
do_write_to_stream - subclasses can then override that implementation if
they want, but can't stop the public function from forwarding to the
implementation (it would be a nasty surprise if a subclass changed
write_to_stream so it forwards to write_to_string instead!)

jon


-- 
Horms and I discussed this, and we came up with two categories of people.
People who use vim, and people who don't realize that they could be using vim.
	- Geoff Harrison




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