Closed nowknowing closed 3 years ago
I think your solution does work: Circle extends Shape implements Scalable UnitCircle extends Shape
If must, I would probably do the following: Circle extends Shape ScalableCircle extends Circle implements Scalable UnitCircle extends Circle
There's an apt quote from Uncle Bob(Robert Cecil Martin), if I may share:
The representatives of things do not share the relationships of the things that they represent.
So a UnitCircle is a Circle in real life, but it may not be appropriate for a UnitCircle "is-a" Circle relationship in code.
Thank you. Right, having a scalableCircle would make sense and is probably necessary. That way UnitCircle is also still in a “is-a” relationship with Circle.
And thanks for interesting words! I should better think/+read about it. Though I also partly find it odd that we(lectures) often quote whoever these people are. I suppose to be quoted there must be some proof to the words.
Robert Cecil Martin is a well known author who promotes writing Clean Code. I think the lectures didn't really introduce people who are better known in the programming community, but I highly recommend watching his talks about design principles and writting clean code. They are highly entertaining! Like this one: https://youtu.be/7EmboKQH8lM ;) maybe after the exam?
Description
Hi I was looking at lecture03 (slide 17 or so) on interface/abstract classes. Is it correct to say that they suggest: Class Circle extends abstract class Shape + implement Scalable interface. And Class UnitCircle should extends abstract class Shape only. Meaning there is no link between Circle and UnitCircle(brought up in lecture02) though its a (is-a) relationship?
Topic:
Interface Abstract class Polymorphism
Screenshots
Screenshots (if any)