4

I have the following sequence diagram to add a student to a list of students. the implementation could be like

List<Student> Students = new List<Student>();
Students.Add(aStudent);

I drew the following sequence diagram for it:

enter image description here

In this diagram Students is actually the list of students mentioned in the code.

I would like to know is it a correct way to show a list of objects as a object lifeline? I mean as a conceptual and analysis approach and also at syntax.

For example maybe the List<Student> could be the object of a general class named Storage which is responsible to store and retrieve a list of objects like a database...

4

Description of lifeline from UML 2.4.1 standard:

A Lifeline is shown using a symbol that consists of a rectangle forming its “head” followed by a vertical line (which may be dashed) that represents the lifetime of the participant. Information identifying the lifeline is displayed inside the rectangle in the following format:

<lifelineident> ::= ([<connectable-element-name>[‘[‘ <selector> ‘]’]] [: <class_name>] [decomposition]) | ‘self’
<selector> ::= <expression>
<decomposition> ::= ‘ref’ <interactionident> [‘strict’]

So, you should rename Students to Students : List<Student> or just :List<Student>. The part after colon (:) represents a type (<class_name> from notation above).

There is no special syntax for representing lists.

EDIT: as for "Student Storage/Adapter"

If List does the job, just use it. It is object-oriented enough as it is. No need to introduce a pattern for the sake of introducing a pattern, and more than so for the sake of writing a busy-sounding class name to a diagram. Keep it simple.

| improve this answer | |
  • I drew it in Visio, for example the class of Form1 is Form but it didn't show it, anyway thank you! but still I didn't get is it a right way to use a list or not! I mainly mean at conceptual analysis and not necessarily syntax – Ahmad Nov 23 '14 at 8:29
  • That is OK at conceptual level too. Your list is a valid participant of a process, and it doesn't really matter if it's a list or something else anyways - it a sequence diagram, not class diagram. – scriptin Nov 23 '14 at 8:32
  • Could we say its actually a class like StudentAdapter or ... which is responsible to keep the list of students or save them in a database or ... So maybe its better to have a class for it where the storage is not specified and manipulation to the storage are shown? I modified my question to add that. – Ahmad Nov 23 '14 at 8:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.