Pre-assessment notes

Subclassing

The key things I wanted you to say were: subclassing lets you use object oriented polymorphism (this is far more important than that it lets you save a little typing); but it introduces tight coupling between the subclass and the superclass. To decide when it's sensible to make T a subclass of S, the main thing you should ask yourself is: is it true that every T is an S? The reason why this is the right question is that then, a client written to handle Ss should indeed be able to handle Ts automatically, which is what OO polymorphism will give you.

Very few people said what I wanted you to say, which goes along with few people understanding OO polymorphism. We'll talk about this. I'm glad I asked!


This page is maintained by Perdita Stevens (perdita@inf.ed.ac.uk)


Home : Teaching : Courses : Seoc : 2014_2015 : Preassessment 

Informatics Forum, 10 Crichton Street, Edinburgh, EH8 9AB, Scotland, UK
Tel: +44 131 651 5661, Fax: +44 131 651 1426, E-mail: school-office@inf.ed.ac.uk
Please contact our webadmin with any comments or corrections. Logging and Cookies
Unless explicitly stated otherwise, all material is copyright © The University of Edinburgh