XOR constraints on attributes by relationship

Please use this forum for open discussions about Bouml.
Merci d'utiliser ce forum pour des discussions ouvertes à propos de Bouml.

XOR constraints on attributes by relationship

Postby adi » Wed 24 Sep 2014 00:33

I tried to find a way of adding a XOR constraint between 2 (works also between 3 or more?) attributes by relationship. There seems to be no information about this detail in the BOUML manual. As shown in attached project, I can "visually" show a {XOR} constraint between a "-automaticTransmission" and a "-manualTransmission" attributes by linking the text "{XOR}" to unidirectional association arrows, using "Anchor/Class association" simple lines. While this works as a visual detail, I would like to know if there is any way to implement the {XOR} condition as a defined logic condition, something that BOUML can translate in C++ code.
x00005-DPF.7z
example with a {XOR} constraint on attributes by relationship.
(5.26 KiB) Downloaded 361 times
adi
 
Posts: 8
Joined: Tue 9 Sep 2014 16:58

Re: XOR constraints on attributes by relationship

Postby Bruno Pagès » Wed 24 Sep 2014 09:27

The constraints are managed by Bouml, even I don't respect at 100% the norm

Because your constraint is between two relations you can define it at the class level or on one of the relations (editing the class or a relation)

By default the constraints are not shown in a class diagram, to show them you have to set the drawing setting "show information note" at the diagram level (or upper) or just for C_Car. This will show the note containing the constraint text (XOR ..), but the anchor will be made with the class (even the constraint will be for a relation), anyway after you can remove the anchor to the class then add new anchors to the relations.

There is no way to generate code from the constraint
ImageAuthor of Bouml
Bruno Pagès
 
Posts: 470
Joined: Mon 20 Feb 2012 08:23
Location: France

Re: XOR constraints on attributes by relationship

Postby adi » Wed 24 Sep 2014 16:55

Dear Bruno, since I am just learning UML/BOUML, here are some stupid questions. It is no way to generate code from a diagram with this special {XOR} condition between two or more attributes because this bit of UML is not implemented in BOUML? I assume the {XOR} condition will be automatically discarded in this case?
Or I am wrong and UML is not supposed to translate this {XOR} stuff in code, it is supposed to discard it?

Cordialement à vous,
Adi
adi
 
Posts: 8
Joined: Tue 9 Sep 2014 16:58

Re: XOR constraints on attributes by relationship

Postby Bruno Pagès » Thu 25 Sep 2014 18:13

Dear Adi,

In UML the constraints can be be written in OCL, or can be free text, OCL being a language it is possible to translate it in 'standard' language like C++/Java/...

Anyway the constraints may have several roles, including documentation purpose, and even it is for code production there are several possibilities. Considering the XOR between your two relations, do you want to produce assertions checking the XOR is true at execution time ? if yes where the assertion must be placed, each time you set one of the relation ? You may not want to produce assertion and for instance to reset a relation when you set the other, etc

Bouml doesn't manage OCL, so the content of the constraints is free, you can set them with OCL code or any other text. Because of that, and because there are several possible goals attached to the constraints the code generators do not consider them.
ImageAuthor of Bouml
Bruno Pagès
 
Posts: 470
Joined: Mon 20 Feb 2012 08:23
Location: France


Return to Open discussions / Discussions ouvertes

Who is online

Users browsing this forum: No registered users and 3 guests