Info

Figure 4-5. Example of unidirectional association between Plant and Weather.

Figure 4-5. Example of unidirectional association between Plant and Weather.

In the example shown in Figure 4-5, only class Plant can access data and behavior defined in class Weather. The role of class Weather is to provide data for class Plant. An attribute of type Weather and named dataProvider will be defined in class Plant to allow access to data and behavior in class Weather.

The same class can play the same role or a different one in associations with other classes. Figure 4-6 shows an example where class Plant plays different roles in different associations with different classes.

Figure 4-6. Example of class Plant playing different roles in different associations.

In Figure 4-6, class Plant plays the role of plant data provider in association with class Soil and the role of data requestor in association with class Weather. In Figure 4-7, class Weather plays the same role, the one of data provider in both associations with classes Soil and Weather.

Figure 4-7. Class Weather plays the same role in two different associations.

While modeling an association, it is important to show how many objects on both sides of the association can be linked together. This process is called association's multiplicity. Figure 4-8 shows an example of multiplicity of an association.

Person

works for

Farm

0 0

Post a comment