Jul. 27th, 2006

jang: (Default)
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.

Profile

jang: (Default)
jang

October 2011

S M T W T F S
      1
2345678
9101112131415
16171819202122
23 242526272829
3031     

Most Popular Tags

Style Credit

Expand Cut Tags

No cut tags
Page generated Sep. 22nd, 2017 05:07 pm
Powered by Dreamwidth Studios