[Exceptional C++ Style] Item 17 - Encapsulation

Adrian Fagg adrianf at evaluategroup.com
Mon Dec 20 08:46:16 EST 2004


> -----Original Message-----
> From: effective-cpp-bounces at accu.org
> [mailto:effective-cpp-bounces at accu.org]On Behalf Of solosnake .

> The author says that the most important thing to get right is
> the class
> interface - everything else can be fixed. Poor interfaces may
> be impossible
> to fix once in use.

OK, this has to be the least controversial point raised so far...

Interfaces are immutable, we all know that don't we?
And yet...
According to the current fashion (which I follow slavishly), software
evolves better than it gets designed. How do you evolve an immutable
interface?
The classic answer is that you sort of breed from it. As well as the old
interface, you add a new, different and better one. Then you end up over the
years with a typical Microsoft COM object supporting IThisInterface,
IThisInterface2, IThisInterface3... IThisInterfaceEx, ....
This must be a maintenance nightmare internally and it isn't necessarily all
that great on the outside either.

I have long had a philosophy of programming with an axe. That is, I like to
break code.:-)
So, rather than continuing to support an old misguided interface that seemed
like a good idea at the time, I get rid of it and replace it with the shiny
new model, thus forcing my long suffering clients (often me), to change
their use of it.
OK, I exaggerate a bit. Nevertheless, there can be times when deep change is
the best thing - the lesser of two evils or an exciting opportunity
depending on point of view.

In fact, I feel that there's something worth discussing here - partly
triggered by Giovanni Asproni's recent agile article, i.e. when is it best
to give up and start afresh in general?
I'll maybe post on accu-general.

Regards,

Adrian

Work: mailto:adrianf at evaluategroup.com
Home: mailto:adrian.fagg at ntlworld.com

Pretty pictures: http://homepage.ntlworld.com/rbyadf/




More information about the Effective-cpp mailing list