[Edu-sig] Introduction to object and "dot" notation: feedback wanted
Andre Roberge
andre.roberge at gmail.com
Thu Jan 19 20:44:44 CET 2006
On 1/19/06, Peter Bowyer <peter at mapledesign.co.uk> wrote:
> At 20:28 18/01/2006, Andre Roberge wrote:
> >Fido.left_front_paw.moves()
>
> I have a query about this call. The way the left_front_paw moves is
> not going to be very different from right_front_paw or the back
> paws. Now if it's identical, in a simplified model, does not
> Fido.moves(Fido.left_front_paw)
> make more sense? It is harder to understand, and I'm not happy with
> the argument to the method, but it promotes code reuse.
>
> Peter
Since this is intended to be the first introduction to the dot
notation, I think it would be a bit more confusing then necessary.
What I want to illustrate is the "chaining" that can occur with using
the dot notation. It is more the notation, than the underlying
implementation that I want to introduce at this point.
In term of promoting code reuse, my first inclination would be to have
something like
Fido.left_front_paw = Paw() # Paw() is a class, with a move() method
Fido.right_front_paw = Paw()
instead of having a method argument.
[One might argue that Fido.move() has to imply that each individual
paws must move, hence your observation about having it as a method
argument instead ... hmmmm... ]
I'll have to think about it further and I thank you for your suggestions.
André
More information about the Edu-sig
mailing list