Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Papyrus » Lifeline refers to one instance of a class?
Lifeline refers to one instance of a class? [message #1205746] Sat, 23 November 2013 19:53 Go to next message
Chriss Matt is currently offline Chriss MattFriend
Messages: 38
Registered: December 2012
Member
Hi !

I am trying to model the following situation:

Professor advises 3 Students:
student1: Student
student2: Student
student3: Student

Multiplicity attached to an association end declares 'how many' objects participate in the relationship. So ,I attached at the near end of Student 3 as a multiplicity (the number of students).

each student has a three operations

(Please see the class diagram)
index.php/fa/16803/0/

Now, I am trying to model the Sequence diagram:

the first lifeline represents a professor instance(through represent property of lifeline)

and then I should create a lifeline for each student (3 lifelines)
when I am trying to select a student using 'represent' I get the same instance of Student class which is named 'student' instance(object)

(Please see the Sequence diagram)
index.php/fa/16804/0/

Is there a way in Papyrus to distinguish among student1,student2,student3 while specifying 'represent' property of each lifeline?
because the order of operation's call differentiate from one student to another ?

I supposed I'll get three instances of Student type because the multiplicity is set to 3


Regards
Chriss
  • Attachment: 1.PNG
    (Size: 10.52KB, Downloaded 1228 times)
  • Attachment: 2.PNG
    (Size: 24.04KB, Downloaded 1724 times)
Re: Lifeline refers to one instance of a class? [message #1209867 is a reply to message #1205746] Mon, 25 November 2013 18:54 Go to previous messageGo to next message
Chriss Matt is currently offline Chriss MattFriend
Messages: 38
Registered: December 2012
Member

I am not sure if what I am trying to do is correct and possible in Papyrus or not?

Any suggestion would be very appreciated.

Chriss
Regards
Re: Lifeline refers to one instance of a class? [message #1211362 is a reply to message #1209867] Tue, 26 November 2013 11:54 Go to previous messageGo to next message
Camille Letavernier is currently offline Camille LetavernierFriend
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 Go to previous messageGo to next message
Chriss Matt is currently offline Chriss MattFriend
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 :
index.php/fa/16876/0/


2)Composite structure diagram:
I model 3 properties of Type Student and
1 property of Type Professor (as you recommended) using composite structure diagram
index.php/fa/16877/0/

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
index.php/fa/16878/0/


#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 1193 times)
  • Attachment: collaboration.PNG
    (Size: 12.56KB, Downloaded 1184 times)
  • Attachment: SD.PNG
    (Size: 18.51KB, Downloaded 1233 times)
Re: Lifeline refers to one instance of a class? [message #1219142 is a reply to message #1215873] Mon, 02 December 2013 11:06 Go to previous messageGo to next message
Chriss Matt is currently offline Chriss MattFriend
Messages: 38
Registered: December 2012
Member
if I understand correctly,Camille has suggested to model 3 properties but I still don't know if these diagrams still invalid and not correct in papyrus or not?

Any hint would be very appreciated.

Chriss
Regards
Re: Lifeline refers to one instance of a class? [message #1219154 is a reply to message #1219142] Mon, 02 December 2013 12:07 Go to previous messageGo to next message
Camille Letavernier is currently offline Camille LetavernierFriend
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
Re: Lifeline refers to one instance of a class? [message #1219177 is a reply to message #1219154] Mon, 02 December 2013 13:40 Go to previous message
Chriss Matt is currently offline Chriss MattFriend
Messages: 38
Registered: December 2012
Member
Camille, I really can't thank you enough for your kind help.

Regards
Chriss
Previous Topic:Versioning for UML Models like for Profiles
Next Topic:Model Validation with Papyrus
Goto Forum:
  


Current Time: Wed Apr 24 20:20:47 GMT 2024

Powered by FUDForum. Page generated in 0.02971 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top