[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:       David Faure <david () mandrakesoft ! com>
Date:       2002-03-06 23:16:28
[Download RAW message or body]

On Wednesday 06 March 2002 23:56, Carsten Pfeiffer wrote:
> 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".

Doesn't s/private/protected/ (in the above example) solve that issue?

-- 
David FAURE, david@mandrakesoft.com, faure@kde.org
http://people.mandrakesoft.com/~david/, http://www.konqueror.org/
KDE, Making The Future of Computing Available Today

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

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