[Qt-interest] Non-Virtual Interface Idiom
Piotr Dobrogost
pd at qtlists.qt.dobrogost.pl
Tue Dec 21 23:06:23 CET 2010
On 2010-12-20 08:25, Andreas Pakulat wrote:
> doDataPhase1&doDataPhase2. And of course it also means you cannot
> override certain aspects of the actual data() implementation and hence
> the concept limits the usability of classes designed this way.
If you can't override certain aspects of base class' behavior that's because someone designed it this way and this is a Good Thing. Each class should be created to handle some task and handling any task means obeying some rules. If you call designing a base class to carry the specific task it was created for "limiting the usability" then think how much helpful would be non limiting class with one virtual member function justDoItRight() :) My point is, the more non limiting a class is the less help you get from it; lack of structure and rules is not inherently valuable.
> So the only benefit is helping people not shooting their own foot by
> preventing them from breaking certain contracts defined by the interface
> class.
I would call it a great benefit; one which makes it desirable to create a base class in the first place.
--
Piotr Dobrogost
"Break C++ and the major implementations of Java and C# would also break" - Bjarne Stroustrup
More information about the Qt-interest-old
mailing list