jeudi 14 mai 2015

A design pattern for objects belonging to two categories, both covering all my object

I would like to design a class diagram for the following problem:

In my domain, my elements, say ELEMENTs, are either INPUT elements, or OUTPUT elements (but not both) from one perspective. From another perspective, they are either NODEs or ARROWs (but not both again). For example, the element e1 can have only one of the following situations: 1) be an input node 2) be an output node 3) be an input arrow 4) be an output arrow. I would like to encode this without using constraint (like OCL)

I am thinking of the following design diagram (grey classes are abstract): enter image description here

My Question: Is there any other pattern that fits this problem better (with smaller diagram and probably without multi-inheritance)?

Aucun commentaire:

Enregistrer un commentaire