News for hackers. Stuff that matters.
Re:Inheritance Often Doesn't Make Sense by jdmichal on Saturday March 17, 2018 @04:02PM (#16608784)
Inheritance can represent this relationship, as long as all the defined operations in the rectangle are covariant. Because squares are covariant (more constrained) than rectangles. This generally means that the rectangle type must be immutable.
Re:Inheritance Often Doesn't Make Sense by mannykannot on Sunday March 18, 2018 @09:27AM (#16611824)
Indeed, but unfortunately these complications almost never comes up when programming in current mainstream object-oriented languages is taught. Usually, the take-home lesson is, "if you have a type hierarchy, use inheritance - it's simple."
Re:Inheritance Often Doesn't Make Sense by jdmichal on Sunday March 18, 2018 @01:00PM (#16612875)
You are absolutely right that there is an education problem. I got lucky by randomly deciding to take the OOP principles elective. It's still not a required course at my school, though I know from recruiting trips that other schools include it.

I think there's a place for a language that separates inheritance from subtyping. A lot of misuse of inheritance that I see comes from inheriting for functionality instead of subtyping.