title: Loop scoping in Sequence diagrams UML
body: <p>Knowing that the "item" is being created within the context of the <code>foreach</code> loop only (as in, it exists in the scope of the <code>foreach</code> loop only), how would you display that within a sequence diagram (UML) by including both the contructor and destructor of the "item" object?</p>
  
  <pre><code>foreach (A item in itemsList)
  {   item.DoStuff(); }
  </code></pre>
  
  <p>Is the way I provided below the correct one for this? Some of the answers for similar questions didn't include the scoping part (as in, the objects were all "already existing" at the head of the diagram, unlike item being created within the loop itself)?</p>
  
  <p><a href="https://i.imgur.com/YqdviTk.png" rel="nofollow noreferrer"><img src="https://i.imgur.com/YqdviTk.png" alt="enter image description here"></a></p>