Modeling Relationships between Objects
In software development, students often struggle with modeling relationships between the various objects in their model. The reason for this is that there are several potential relationships to choose from including inheritance, composition, association and interface implementation.
I try to remind students that is important that their application model closely reflects the real world model to avoid potential problems. I will often do exercises with them where we discuss the relationship between objects in a physical world. For example, we will discuss the relationships between students and people; car and engine; student and registration; customer and hair dresser.
I explain to them that students “are a” type of person which implies inheritance; a car “has” wheels which implies composition; and a student “can do” registration implies interface implementation. Finally, a person “uses a” hair dresser which implies association.
I will then encourage students to discuss other relationships in the real world that they are familiar with and connect these relationships to the appropriate relationships in their software development model.
TweetExample for "Modeling Relationships between Objects":
n/a