[Tutor] Inheritance help

Alan Gauld alan.gauld at btinternet.com
Thu Jul 3 11:14:02 CEST 2008

"Kent Johnson" <kent37 at tds.net> wrote

> Hmm. I don't understand the LSP to make any requirements on the
> constructors. It says that instances of a subclass should be
> substitutable for instances of the base class, it doesn't say 
> anthing
> how the instances are created.

LSP doesn't distinguish between method types but the substitution
principle can extend beyond instances to include class methods etc.

The issue is that you could have a collection of class references
and have a loop that creates instances from those. To do that the
constructor calls need to be compatible in signature for the LSP
to apply.

Its much less common for the LSP to be strictly applied to 
because in many languages class references are either non existent
or a bit of a kluge. But in languages that support classes as objects
then applying LSP at the conastructor and class method level
makes a lot of sense.

Alan G. 

More information about the Tutor mailing list