I have some code, which I want to present in UML, but I've stuck at one point. Let me tell you something about code's functionality.
I have a workspace in which I can place some Component
s, select them, delete, add new, move etc. I can also connect them according to some rules (there are different types of Component
s available). In order to determine if a group of Component
s can be connected or not, I've implemented some easy mechanism. In this mechanism the following parts appear:
[EDIT: Please note, that "PlausibilityRule" in UML and "ConnectionRule" are the same things - it's my oversight]
ConnectionRule
- get the type of connection, and checks if a collection of Component
s given as a parameter can be connected according to this ConnectionRule
.
ConnectionRulesSet
- has many rules inside. Client asks a set with rules like this: "according to which rules definied in a set, components given as a parameter, can be connected"? ConnectionRulesSet
gives a list of ConnectionRules
as a response. A concrete Connection rules set are exposed only throug interface - Client cannot create an instance of a concrete RulesSet.
RulesSetFactory
- depending on many circumstances, application can use different ConnectionRulesSet
s. That's why I've created a factory which gives a proper implemetation of ConnectionRulesSet
interface depending on specified circumstances.
And now let's take a look at the Client's code:
// list of components which should be verified in terms of connection plausibility:
List<Component> selectedComponents = ... ;
// Get set of rules for normal conditions:
ConnectionRulesSet setOfRules = RulesSetFactory.getRulesSet(NORMAL_SET);
List<ConnectionRule> fulfilledRules = setOfRules.getFulfilledRules(final selectedComponents);
// Do something with fulfilled rules:
for(PlausibilityRule rule : fulfilledRules){
addToAvailableRulesList(rule.getConnectionType().getName()); // display names of connetion types...
}
My problem is, that I'm not sure how to create an UML class diagram for such solution from Client's perspective... How to expose relationships between presented solution and a Client. Client uses actually all: ConnectionRule, RulesSet, RulesSetFactory...
There is one of my ideas below... What do you think? Have you got any better solution?
PlausibilityRule
the same concept asConnectionRule
? If not: a) What is the difference? and b) Where isConnectionRule
(as opposed toConnectionRulesSet
) in the diagram? – Tersosauros Feb 28 '16 at 5:16ConnectionRulesSet
just an aggregation/composition ofConnectionRule
's? Or is there more responsibility meant by theConnectionRulesSet
having the behavior togetFulfilledRules
? – Tersosauros Feb 28 '16 at 18:58ConnectionRulesSet
(which I believe under most OOP naming conventions would/should be "ConnectionRuleSet
" - It's one set, of zero or moreConnectionRule
's, notConnectionRules
..) - has both a behavioural responsibility (filtering rules), and an aggregation responsibility (being a set of rules)? – Tersosauros Mar 1 '16 at 22:13