Re: A Design Problem



On Fri, 24 Aug 2007 16:35:36 -0400, Daniel T. wrote:

Nick Keighley <nick_keighley_nospam@xxxxxxxxxxx> wrote:

-> Tool class will have all the methods which can be called on at
least one type of tool and have the default implementation which will
just throw some exception.

ah. that frightened me as well. I was thinking a do-nothing method
instead was a good idea, but apparently not.

A do-nothing method is perfectly acceptable, and IMHO preferred. Just
keep in mind, this means the method can have no post-condition (strictly
speaking the post-condition is "true".)

No, this is the postcondition of an implementation for this *specific*
type. The postcondition of the class, will not be satisfied that easily.
Compare this with multiplication by a number. If the multiplicand is 0 you
need not to do anything to get the result. But this does not mean that it
would be same for all other numbers. Multiplication has "non-trivial" sense
even, if it occasionally is idempotent in 0.

The natural question then becomes, why bother calling such a method? You
see, the purpose of the method changes in this case. You are calling the
method to inform the object of something, rather than to get it to do
something.

Uhm, what is semantic difference between "doing" and "being informed"? I
bet there is no one. The postcondition of the method is "yes sir! Informed,
sir!" I suggest that an informed object differs to an uniformed one. At
least it should accept "I told you so." Otherwise there were really no
sense in having this method.

This changes the entire design paradigm from procedural to OO.

You should be sending messages to objects, informing it of things it
wants to know about, not sending commands demanding it change its state
in a particular way.

Oh, hmm, I would say this is rather declarative vs. imperative. Robert
Martin claims that OO is all about dispatch. I think that is imprecise too,
but much closer. However this is an old discussion for another day.

--
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de
.