-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1


On May 17, 2008, at 12:55 AM, Keith Bennett wrote:

> Florian, your example is not a fair one; it illustrates an intentional
> violation of the semantics, whereas Roger is referring to an
> accidental one.  In fact, it illustrates the lengths to which one must
> go to trigger the problem in Java.

Actually, you don't have to go that far :). I know, the example is a
artificial.

Actually, i did only add the interface for illustration. A more common  
case
would  be the assumption that methods of subclasses share
common semantics with methods of superclasses. I had such
a case some time ago, when a fellow student assumed that a method
name was not taken and implemented it on a subclass, causing havoc
in the code calling it :). Granted, this is an indicator that the naming
was too generic, but the language didn't help a bit.

But the question was:

 >How can anyone assume that just because a method exists that the
 >semantics is the same?

This problem is present in both Java and Ruby and none of the
languages helps me much in this. It is much more a question of
programmers discipline, good naming and knowledge of the
ecosystem the software lives in :). Thats perhaps why you don't
experience it as a big problem. Considering that i assume that
ruby is not the first OOP-Language for many people, they've
already got a headstart when it comes to this.

But actually, i can produce a real-world sample for an interesting  
semantic
changing behaviour that is much harder to reproduce in Java/C# and
would really be abuse in such languages.

If you know you way around ActiveRecord, calling #find on associated set
of models (e.g. @some_person.friends.find) will not call Array#find but
Friend.find. _But_ if you try inspecting the Object, it will happily  
tell you that
it is an Array. (and not some subclass ...) 
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.8 (Darwin)

iEYEARECAAYFAkguItkACgkQJA/zY0IIRZbmsACgujIPlOK7pEM5AeqEEWLf1aYI
mAsAnAjlb3EKVHGFGF/Jn5pBDBVul0AS
=aT3y
-----END PGP SIGNATURE-----