NVI - Nonvirtual Interface pattern.

As some of you might know, I am a sucker for books.

This time I have read "Exceptional C++ Style" by Herb Sutter. There I
came across Item 18, about Virtuality.

The conclusion of that chapter is:

"Prefer to make base class virtual functions private (or protected if
you really must). This separates the concers of interface and
implementation, which stabilizes interfaces and makes implementation
decisions easier to change and refactor later. For normal base class
functions: 

           - Guideline #1: Prefer to make interfaces nonvirtual, using
             the Nonvirtual Interface pattern (NVI).
           - Guideline #2: Prefer to make virtual functions private.
           - Guideline #3: Only if derived classes need to invoke the
             base implementation of a virtual function, make the
             virtual function protected.
"

This fit perfectly with my own views, so I just had to jump along and
try it out. IMHO the result is _very_ nice, even if I am only half way
through. 

Anyway... I am not planning to commit this now, but I'll show you what
I have anyway. Note that the patch actually fixes a couple of bugs as
well:
        - Insets missing CODE
        - Unused functions
        - Unneeded implementaions

well here it is:

Attachment: nvi-1.diff.gz
Description: GNU Zip compressed data

-- 
        Lgb

Reply via email to