Reputation: 219
I'm beginning with UML and i'm trying to create a class diagram for a simple online shopping application. I would like to know if i should create an association beetween the following classes:
The responsability of the CardVerificator class is to check with the payment system if a card is valid or not. This class has one method with the following signature: verifyCard(Card):void (The method raises an exception when the given card is not valid).
(Sorry for my bad english) Thank you.
Upvotes: 2
Views: 217
Reputation: 5864
You don't need an association here, only a dependency between those classes.
Association comes in the action, when you need a permanent, long-term link between the corresponding objects. In code is this situation often reflected through data members. Here we speak about a short-term limited contact that should even not be persisted (a simple method parameter instead of a data member).
CardVerificator should of course "know" the "Card" concept in order to be able to verify it, but this is nicely explained with a simple generic dependency:
Upvotes: 2