The following domain requirements set the stage for association classes:
Where in the UP Domain Model should the merchant ID attribute reside?
Placing merchantID in Store is incorrect because a Store can have more than one value for merchantID. The same is true with placing it in Authorization - Service.
Figure 31.14 Inappropriate use of an attribute
This leads to the following modeling principle:
Guideline : In a domain model, if a class C can simultaneously have many values for the same kind of attribute A, do not place attribute A in C. Place attribute A in another class that is associated with C.
For example : A Person may have many phone numbers. Place phone number in another class, such as PhoneNumber or Contact lnformation, and associate many of these to Person.
Figure 31.15 First attempt at modeling the merchantID problem
The above principle suggests that something like the model in Figure is more appropriate. In the business world, what concept formally records the information related to the services that a service provides to a customer? A Contract or Account.
The fact that both Store and AuthorizationService are related to ServiceContract is a clue that it is dependent on the relationship between the two. The merchantID may be thought of as an attribute related to the association between Store and AuthorizationService.
This leads to the notion of an association class, in which we can add features to the association itself. ServiceContract may be modeled as an association class related to the association between Store and AuthorizationService.
In the UML, this is illustrated with a dashed line from the association to the association class. Figure visually communicates the idea that a Service - Contract and its attributes are related to the association between a Store and AuthorizationService, and that the lifetime of the ServiceContract is dependent on the relationship.
Figure 31.16 An association class
Figure 31.17 Association classes
Guidelines for adding association classes include the following:
Guideline : Clues that an association class might be useful in a domain model:
The presence of a many - to - many association is a common clue that a useful association class is lurking in the background somewhere; when you see one, consider an association class.
UML Related Interview Questions
|Adv Java Interview Questions||Java collections framework Interview Questions|
|Design Patterns Interview Questions||Rational robot Interview Questions|
|Web semantic Interview Questions||Spring MVC Framework Interview Questions|
|Advanced C++ Interview Questions||Advanced jQuery Interview Questions|
|XML DOM Interview Questions||Object Oriented Analysis and Design Interview Questions|
All rights reserved © 2020 Wisdom IT Services India Pvt. Ltd
Wisdomjobs.com is one of the best job search sites in India.