Re:A Square Is Not A Rectangle
by KevinMS on Monday September 14, 2009 @04:09PM
(#822504)
Problem is from historical conventions of what a square and rectangle are.
A square is not really a thing, its a description of a thing. In this case, proportions of the sides of a shape.
So when you translate this into object oriented language, you are subclassing a concept with one of its potential variations. It would be like making a class called MusicalNote and then a subclass named MusicalNoteC, even though MusicalNote already has it covered.
So "square" shouldn't be a subclass because its just a proportion of the data within "rectangle", so more appriopriately, 'square' would be a method of Rectangle since it deals with internal data.
A square is not really a thing, its a description of a thing. In this case, proportions of the sides of a shape.
So when you translate this into object oriented language, you are subclassing a concept with one of its potential variations. It would be like making a class called MusicalNote and then a subclass named MusicalNoteC, even though MusicalNote already has it covered.
So "square" shouldn't be a subclass because its just a proportion of the data within "rectangle", so more appriopriately, 'square' would be a method of Rectangle since it deals with internal data.