Kragen Javier Sitaker | 22 Aug 09:37 2011

Goodbye, shitty Car extends Vehicle object-orientation tutorial

I propose a new rule for discussions of object-oriented programming:

> **Anyone who brings up examples of Dog, Bike, Car, Person,
> or other real-world objects, unless they are talking about writing a
> clone of The Sims or something, is immediately shot**.

I feel that this new policy will improve the quality of the discourse
enormously.

[Henning Koch wrote][] about his encounter with dependency injection:

> Aside from having snorted coke through my nose over “nearly
> tautologic diagrams” I feel the need to defend Martin Fowler’s
> [article][Fowler] because it had such a profound effect on me when
> it was published. Although I had been playing with “objects” and
> “classes” before, this article finally made me understand what OOP
> was all about. This is not true for many other articles and yes, I’m
> looking at you, shitty `Car extends Vehicle` OOP tutorial.

[Henning Koch wrote]: http://www.netalive.org/swsu/archives/2005/10/in_defense_of_the_nearly_tautologic_diagram_1.html
  (Henning Koch, posted on blog “Software will Save Us”, 2005-10-13, “In defense of the nearly
tautologic diagram”)
[Fowler]: http://martinfowler.com/articles/injection.html
  (Inversion of Control Containers and the Dependency Injection pattern, by Martin Fowler, 2004-01-23)

Why `Car extends Vehicle` or `Duck extends Bird` are terrible examples.
-----------------------------------------------------------------------

The `Car extends Vehicle` or `Duck extends Bird` type of tutorial
obscures more than it illuminates.  In good OO programming, we don’t
(Continue reading)

Dave Long | 30 Aug 12:16 2011
Picon

Re: Goodbye, shitty Car extends Vehicle object-orientation tutorial

Did anyone actually come up with a reasonable example?  (a cursory  
glance at eiffel docs reveals they don't have a killer example either)

It could be that objects are like coroutines; they need a moderate  
amount of complexity for their advantages to become apparent.  What's  
the object equivalent of samefringe?

> Object-orientation lets you have:
>
> - more than one object implementing the same protocol;
> - more than one method defined in the same protocol;
> - more than one protocol implemented in the same object;
> - methods and instance variables defined in different classes in the
>   ancestry of an object.
>
> An ideal example would show all four of these kinds of variation.

Sketchpad[0] had polymorphism for geometry (drawing and hit testing 
[1]) and topological constraints.  I'm not sure, but it seems that  
instances of his "partly flexible arrow" are examples of objects  
which have been constructed so as to have variables and constraints  
at different points in their "ancestry".  (what role did the  
"masters" play wrt to instances? sketchpad may have been more  
prototype- than object-oriented)

However, while the implementation was certainly small, I doubt the  
concepts are simple enough to serve as an introduction.

-Dave

(Continue reading)


Gmane