[Exceptional C++ Style] Item 18 - Virtuality

Timothy Wright tcw321 at gmail.com
Wed Jan 5 09:38:14 EST 2005


> 
> Yes indeed. The trouble is that Sutter writes on this so compellingly, that it feels almost churlish to argue against it. It actually convinced me for several hours when I first read this, but as Kevlin has already said, it's the Template Method aspect that rings the bell.
> I wouldn't go so far as to say that NVI is never the right thing. There are some scenarios in languages other than C++ where NVI is a recognisable idiom.

I have believed in Herb's comments and started implementing it in some
code.  My thoughts were that I have code that is in constant flux.  I
usually only have a couple of days if that to add features under the
gun.  So if I had that extra indirection, maybe it would help me with
hacking (oop's I mean refactoring) the code to get something done in a
hurry.  But then I understand Kevlin's and others comments too.  It
adds complexity.  And I have not seen any benefits yet of where I have
implemented NVI

To expand something I think Kevlin has hinted on is that most
programming books concentrate on language issues including Herb's
books which I enjoy.  However, I am still at a loss on how to define a
good design, regardless of language.  I measure it by coding something
and see if it gives me trouble in the next few months.  Trouble in the
sense of repeating mistakes, making many small corrections etc.  When
do I know if I have a good design?  Then I get a new  requirement that
blows away what I have done.  I thought that NVI was a good
abstraction, if seen then the design is good but now I am not sure.

Regards

Tim



More information about the Effective-cpp mailing list