MilindaD
MilindaD

Reputation: 7653

Conceptually looping and breaking in a sequence diagram

What I am doing is get the marks of each and every student for a course, here I have created an explicit lifeline for students (the student list in the course object) and then even added a "get(indexValue)" method to show that it is iterated over to get each student.

The issue is that I wish to be a bit less detailed and more conceptual, how should I structure my diagram in order to show that there is looping over all the students in the course without explicitly defining it by using a studeentList lifeline and using a "get(indexValue)" method as seen in lists in Java.

Additionally is this representation correct if having a more detailed diagram was the objective as well. Also regarding breaking a loop I have used a return statement in a loop (as seen in programming languages), I have also seen some versions on the internet use "break" fragments to highlight this, is there a need to be specific for that either

Diagram

Upvotes: 1

Views: 10203

Answers (1)

Bruce
Bruce

Reputation: 2310

You can put a loop box around the parts of the lifelines involved in the loop. In notes for the loop, you enter the continue/exit conditions. There are no "break" or "return" UML constructs. That is an implementation detail.

That said, if you want to get information for each student, I believe you'll have to use the studentList class to get info for each student in the loop. However, you can have one sequence diagram for how you handle each student and then the loop and the list are not necessary.

Remember that each sequence diagram has a precondition, a single scenario, and a post-condition. You can combine diagrams to show more complex behavior and decisions.

Upvotes: 1

Related Questions