Jonathan M Davis wrote:

 It would not be good to be unable to do NVI.

I am not saying that it should not be supported; but...

I've used NVI a number of times myself until I was convinced by Kevlin Henney that it was "a solution in search of a problem" during one of his many excellent presentations at the Silicon Valley ACCU:

  http://www.accu-usa.org/Slides/ACriticalViewOfCppPractices.pdf

A couple of slides can't convey his thoughts, but here they are:

<quote slide="27">
Non-virtual Interfaces?

NVI suggests virtuals should be private and wrapped in public
non-virtuals

 Over the last decade or so this has been proposed by some as a
 good practice guideline

 It has structural similarities with Template Method, but has a
 distinct form and (in)distinct motivation

However, it is a solution in search of a problem

 On close inspection the problems it purports to resolve are
 better addressed by other more mature and proven techniques,
 e.g. the Interceptor pattern
</quote>

<quote slide="28">
Non-Valuable Idiom

NVI lacks either a clear motivation or a clear description of
benefits

 Motivation is often presented in terms of shotgun speculation —
 code simplification, instrumentation, extensibility, decoupling,
 thread safety, assertion checking, etc. — that does not stand up
 to scrutiny

NVI singularly fails to adequately offer the benefits that are
advertised as its motivation

 In practice it is a somewhat tedious and verbose technique that
 adds baggage to a class hierarchy
</quote>

Ali

Reply via email to