I am drawing a conceptual UML Class Diagram based on an Observer Pattern between a UI layer and a mapped domain, where the publisher pushes notifications in the form of SQL queries to the different classes creating records in a SQL database. The model so far looks as following (purely conceptual, note the not yet implemented methods from the ISubscriber interface):
I have some questions regarding the different types of associations between the classes.
DataAccess class
supposed to contain the SqlConnection? Assuming the interface methods are overwritten and pushes SQl queries to DataAccess class
The IPublisher needs to know its subscribers to be able to push the notifications. This means that there is an association between the IPublisher
and *
ISubscriber
.
Since the IPublisher
needs to find efficiently its subscribers, you may even indicate that the association is navigable from publisher to subscriber.
It is not clear if your design should allow an ISubscriber
to subscribe to only one IPublisher
or if it can subscribe to more than one. If you already know, you may wish to specify the opposite multiplicity accordingly. Keep in mind that implementations of the observer pattern with multi-subscription, rarely need a reverse navigability: usually, the notification is then designed in a way to indicate the relevant publisher (e.g.: ISubscriber would have a notify(IPublisher from)
operation or reception.
Regarding the associations of domain classes with data access classes, your question is too broad, as it depends on your chosen architecture. For example, you may use: