Class Diagram: Association & Aggregation Relationships – Georgia Tech – Software Development Process


The next example of relationship we’re going to look at is the association relationship. This is a relationship in which objects of one class are connected to objects of another. And it’s called an has a relationship. So it means that objects of one class have objects of another class. So let’s see what that means. Let’s do it by considering two classes in our example system. The student class and the course offering class. In this case, there is an association between the student and the course offering, because the student is registering for the course offering. So, in a sense, the course offering has students. Contains students, to indicate this fact we add a solid line between the student class and the course offering. And the fact that having a solid line doesn’t really tell us much about the nature of the relationship, so to clarify such nature we can use what we call adornments that we can apply to associations we can add to associations to clarify their meaning. In particular we can add a label to an association and the label describes the nature of the relationship. In this case, for example, it clarifies that the student registers for CourseOffering. We can also add a triangle to further clarify the direction of the relationship. So in this case, the triangle will indicate that it’s the student That registers for the course offering, and not the other way around. Another important adornment or limitation that we can put on an association, is multiplicity. Multiplicity defines the number of instances of one class that are related to one instance of the other class. We can define multiplicity at either end of the relationship. In this case, for instance, we can say that if we look at the student, the student can register for two or more course offerings. Whereas, if we look at the course offering, we can say that each course offering can have or can enroll between 1 and 50 students. So as you can see by adding a label, a direction, and multiplicity, we make it much clearer what the relationship is and what it means and what are its characteristics. As we saw when we introduced relationships, there is a different kind of association, kind of a specialized one, which we call aggregation. So here we’re going to look at an example of an aggregation. So first of all what is an aggregation? An aggregation is a relationship between 2 classes in which 1 represents a larger class like a whole which consists of smaller classes which are the parts of this whole. So let’s look at an example in the context of our system. Let’s consider a Course and the CourseOffering. And in this case, we can see that the Course consists of multiple CourseOfferings. So in a sense, a course is a whole and the course offerings are the parts of this whole. So this a perfect case in which we will use an aggregation to express this relationship. So we will add a solid line with a diamond on the side of the whole class to indicate that the course consists of multiple course offerings. And as we did for associations even though we are not going to do it for this specific example, we could also in this case add multiplicity information on the aggregation to indicate how many classes of the two types are involved in the relationships.




Comments

Leave a Reply

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