0
votes

I have two classes Person and Department with two associations between them

  • works and
  • manages,

and between these two associations there is a {subset} (manages associations are subset of works association).

What should I infer about the object diagram?

  1. Each Person which is a manager has two links to his department (one for works and the second for manages), or
  2. each Person which is manager has only one link to his department?

By the way, besides {subset}, {nand}, {and} and {xor}, is there any other constraint notation which you can put in a class diagram?

3
Welcome to StackOverflow, @tomiliJons. If you found an answer to your question, please consider accepting it (by clicking the check-mark), and consider up-voting it (by clicking the up arrow). Accepting an answer indicates to the wider community that you've found a solution, gives yourself some reputation points, and gives some reputation points to the person who answered your question. If you did not find a satisfactory answer to your question, please leave a comment.Jim L.

3 Answers

0
votes

Since you have defined two associations the objects will have two links. Simple as that. You might add a note that works is redundant in case manages has a non-zero multiplicity (since it will have one of 0..1).

You can place any constraint you like between associations - as long as they make sense.

Superstructures 2.5 states on p.111:

<prop-modifier> indicates a modifier that applies to the Property.

<prop-modifier> ::= ‘readOnly’ | ‘union’ | ‘subsets’ <property-name> | ‘redefines’ <property-name> | ‘ordered’ | ‘unordered’ | ‘unique’ | ‘nonunique’ | ‘seq’ | ‘sequence’ | ‘id’ | <prop-constraint>

0
votes

Notice that a subsets constraint can be defined between association ends (reference properies), but not between associations. So, your question should be better stated as follows. Given a class Person with the two reference properies managedDepartment and department, representing corresponding functional associations between Person and Department, the constraint

managedDepartment subsets department 

implies that for any person object p, the set of departments managed by p is a subset of or eqal to the set of departments p works for. This formalizes the business rule that a person can only be the manager of a department at which (s)he works. Symbolically,

p.managedDepartment subseteq p.department

Alternatively, one could define that the manages association specializes the worksAt association, which would imply that for any manages link there is a corresponding worksAt link.

0
votes

This is the best question I've seen in a while! To answer your two questions directly:

  • Yes, by using Person manages {subsets works for} Department, each Person who is a manager will have two links to Department: one for works for and one for manages.
  • Another useful constraint you can use on a property in a class diagram is {redefines}.

Redefining a property allows you to change a property's name and tighten constraints within the context of its owning class (and within the context of subclasses). For example, you can say the following things:

  • In general, Deck contains 0..52 Cards
  • A subclass of Deck called Monster Deck only contains {redefines contains} 0..10 Monster Cards
  • Another subclass of Deck called Player Deck only contains {redefines contains} 0..10 Player Cards
  • And so on..

This is very handy for expressing requirements and business rules.