Pregunta

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:

  1. Card: A payment card
  2. CardVerificator.

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.

¿Fue útil?

Solución

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:

enter image description here

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top