|
|
Re: Lifeline refers to one instance of a class? [message #1211362 is a reply to message #1209867] |
Tue, 26 November 2013 11:54 |
Camille Letavernier Messages: 952 Registered: February 2011 |
Senior Member |
|
|
Hi Chriss,
First, Lifelines do not represent "Instances", they represent "Parts" or "References", which is quite different (You basically have the same difference in a Composite Structure diagrams). This means that you can have several instances of a "Classrom", each of them with one Professor and 1..* students, and your Interaction should be able to capture all the possible instances.
For collections, there is a "Selector" property which can be used to filter a specific element in this collection. However, the UML specification lacks examples, and I don't really see how you should use it for your specific case. Because you have 3 specific "instances" of Students, then maybe you should actually model 3 properties. If you have "N" students (Multiplicity 1..*), and N can be pretty random, then probably you'll need to be able to distinguish your students with some specific expressions (e.g. an OCL expression: self->any(name = 'John'), if your Class "Student" has a "name" property).
However, the selector is not represented on the diagram. To distinguish graphically your lifelines, you can display the name of the Lifeline instead of the "represents" property (See the Appearance tab of the Lifeline).
Regards,
Camille
Camille Letavernier
|
|
|
Re: Lifeline refers to one instance of a class? [message #1215873 is a reply to message #1211362] |
Thu, 28 November 2013 08:18 |
Chriss Matt Messages: 38 Registered: December 2012 |
Member |
|
|
Camille,Thank you very much for helpful suggestions .Please this is another try I hope I see your comments on that to check if I understand your suggestions correctly or not :
1)Class diagram :
2)Composite structure diagram:
I model 3 properties of Type Student and
1 property of Type Professor (as you recommended) using composite structure diagram
3)Sequence diagram:
the first lifeline represents professor, property of collaboration(through represent property of lifeline)
the second lifeline represents student1, property of collaboration(through represent property of lifeline)
the third lifeline represents student2, property of collaboration(through represent property of lifeline)
the fourth lifeline represents student3, property of collaboration(through represent property of lifeline
#I really read a lot about selector but I don't know how it can be used
so,I leave it without edit(at least for now)
Regards
Chriss
-
Attachment: class.PNG
(Size: 11.02KB, Downloaded 1240 times) -
Attachment: collaboration.PNG
(Size: 12.56KB, Downloaded 1217 times) -
Attachment: SD.PNG
(Size: 18.51KB, Downloaded 1271 times)
|
|
|
|
Re: Lifeline refers to one instance of a class? [message #1219154 is a reply to message #1219142] |
Mon, 02 December 2013 12:07 |
Camille Letavernier Messages: 952 Registered: February 2011 |
Senior Member |
|
|
Hi Chriss,
It really depends on what you want to model. If you want to model a very specific Classroom with a specific Professor and exactly 3 specific students, then this is valid.
If you want to model a generic classroom, and represent one specific example of the interactions within this generic Classroom, then you should go for multivalued properties (But in this case, you should probably use the [0..*] mutiplicity for Students, instead of [3]). And you'd also need to use lifeline selector to represent specific Students (With e.g. an OpaqueExpression with Language = OCL and body = resp. students->at(0), students->at(1), students->at(2), and a little bit of extra work for graphical presentation, to have different labels for each lifeline).
Regards,
Camille
Camille Letavernier
|
|
|
|
Powered by
FUDForum. Page generated in 0.04636 seconds