Re: Restricting access should be illegal?
Gerhard Menzl wrote:
[...]
Template Method is a valuable pattern when the template method
does some processing of its own, such as implementing Design
by Contract. For simple callback interfaces, as in Observer,
this is typically not needed, and maintaining do-nothing
wrappers just for the sake of rigidity and not confusing Java
programmers would be grotesque.
First a nit: design by contract is not the template pattern. In
C++, the two look superficially alike, since they are based on
the same language feature, but the intent is different, and the
implementations look different in other languages (and may look
different in a future version of C++).
And of course, there are cases where you have no contract; in
such cases, using the design by contract pattern to enforce
something that isn't there by design is just silly (which is
basically what you are saying). Typically, this is the case
with various notifications, callbacks and what have you's. (I
believe the Kevlin Henney calls this inversion of control flow.
Basically, it occurs when the reason someone is calling you is
because you asked him to.)
--
James Kanze GABI Software
Conseils en informatique orient?e objet/
Beratung in objektorientierter Datenverarbeitung
9 place S?mard, 78210 St.-Cyr-l'?cole, France, +33 (0)1 30 23 00 34
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]