Someone doesn't get it: object orientation.

Jul 27, 2006 15:31

The register is a rag, let's face it. Here's an example: Code inheritance and reuse: a delicate balancing act. Read down the first page.

[[[
Changes to the external protocol

When a subclass adds new methods that are available outside the class, it changes the external protocol of the superclass. This happens in a number of different situations:

...

* The subclass restricts methods provided by the superclass. This may include removing methods, or changing method parameters to types that are more restrictive. Currently, there is no way in Java to restrict the methods inherited from a class.
]]]

Nor will there ever be. How very 90s: the author doesn't understand what "is-a" means. Clueless feckwit.

Note, it's perfectly OK for a subclass to provide a method that accepts broader types as parameters, or whose return type specification is a subtype of the parent method's. (Although the JVM has a little trouble with this due to the way it locates methods; you have to fake this, but that's an implementatino detail.)

One might find it surprising that the author doesn't mention contracts in his discussion of componentisation. On the other hand, the error here wouldn't be made by someone who understood them.
Previous post Next post
Up