From: Josh Cheek Date: 2012-02-04T23:56:39+09:00 Subject: Re: Inheritance in other notation --f46d0442816ac5d16b04b824a240 Content-Type: text/plain; charset=ISO-8859-1 On Sat, Feb 4, 2012 at 7:03 AM, Robert Klemme wrote: > On Sat, Feb 4, 2012 at 2:14 AM, Jeremy Bopp wrote: > > > The constant Square is a class effectively equivalent to conventionally > created classes, so you don't have to do anything special to make Rectangle > descend from it. Just do it as you originally expected: > > > > class Rectangle < Square > > ... > > end > > Which leaves us with the "minor" issue that a rectangle _is not_ a > square - it's the other way round. Yeah, I know, implementation > inheritance vs. conceptual inheritance. But OP should be aware of > this. > > Kind regards > > robert > > > -- > remember.guy do |as, often| as.you_can - without end > http://blog.rubybestpractices.com/ > > Probably neither should inherit from the other since they break Liskov Substitution Principle. rect.x = 2 rect.y = 4 Now what is the value of rect.x? When rectangle, this will be 2. When square, will it be 4? Squares don't have setters/getters for individual sides since their sides must change together. --f46d0442816ac5d16b04b824a240--