On object-oriented design

On object-oriented design: “… Should I derive the class Polyline from the class Point? This has fairly obvious answer. A Polyline is clearly not a kind of point, so it is not logical to derive the class Polyline from the Point class. This is an elementary demonstration of what is often referred to as the ‘is a‘ test. If you can say that one kind of object ‘is a’ specialized form of another kind of object you may have a good case for a derived class…. The complement to the ‘is a’ test is a ‘has a‘ test. If one object ‘has a’ component that is an object of another class, you have a case for a class member. A House object ‘has a’ door, so a Door variable is likely to be a member of the class House.” [pg 254 of Beginning Java 2]

Leave a Reply

Your email address will not be published. Required fields are marked *