From: Karl von Laudermann Date: 2008-11-05T23:29:10+09:00 Subject: Re: Ruby's take on S.O.L.I.D. On Nov 4, 5:45 pm, Mike Lopke wrote: > For example, the typical Liskov Substitution example you see in Java has > the case where you have a Rectangle class and a derived Square class. > The Rectangle has an independent width and height. They have to be the > same for the Square. One guiding principle when designing a class heirarchy is that the class with fewer data members should be the superclass, and the class with more data members should be the subclass. This sometimes leads to cases which are counterintuitive with respect to the way we think of things in real life. For example, Rectangle should be a subclass of Square, not the other way around. This is because the Square class only needs one dimension member variable, e.g. "width", and the Rectangle subclass needs to add a second one, e.g. "height".