[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-core-devel
Subject:    Re: KParts API: thinking about the future (patch)
From:       Carsten Pfeiffer <carpdjih () cetus ! zrz ! tu-berlin ! de>
Date:       2002-03-06 22:56:38
[Download RAW message or body]

On Sunday 03 March 2002 22:17, Martijn Klingens wrote:

> Would it be a good idea to use the Template Method pattern instead that
> Dawit mentioned on kde-cvs last week? That might be even more flexible.
> What the API would be like then is
>
> public:
>   bool openStream() { return doOpenStream(); }
>   bool writeStream( const QDataStream &s ) { return doWriteStream( s ); }
>   bool closeStream() { return doCloseStream(); }
> private:
>   virtual bool doOpenStream() { return false; }
>   virtual bool doWriteStream( const QDataStream& ) { return false; }
>   virtual bool doCloseStream() { return false; }

There's a drawback in that pattern tho. Imagine you inheriting some other 
part,  needing to reimplement the virtual methods. Whoops, you can't call the 
baseclass' implementation anymore. The topmost superclass is fine, as it has 
the non-virtual method, but the one(s) in the middle "dry out".

Cheers
Carsten Pfeiffer
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic