Nesting Limits and Guard Resolution
The UML specification does not define a formal maximum nesting depth for combined fragments. From a semantic standpoint, fragments such as alt, opt, loop, and par can be nested indefinitely. However, practical limits are typically imposed by the modeling tool's memory management or the human capacity to interpret the resulting diagram.
Guard Resolution in Nested Fragments
When an alt fragment is nested inside a par fragment, the resolution of guard conditions follows the standard scoping rules of the UML execution model:
- Independence: Each concurrent path within the
par fragment is executed independently. If one path contains an alt block, the guard conditions within that alt block are evaluated only within the context of that specific concurrent thread of execution.
- Local Scope: Guards in the nested
alt fragment do not affect the execution of other parallel paths in the parent par fragment.
- State Consistency: The specification assumes that guards are evaluated based on the state of the system at the moment the execution flow reaches the fragment. In a
par block, if multiple paths attempt to modify the same state used by a nested alt guard, the behavior is technically non-deterministic unless external synchronization (such as critical regions) is modeled.
Practical Verification of Tool Limits
Because the UML standard is permissive, you must verify the constraints of your specific software implementation. To determine the operational limit of your tool, use the following scoped test:
- Create a new sequence diagram.
- Insert a combined fragment (e.g.,
alt).
- Iteratively nest a new combined fragment inside the innermost existing fragment.
- Continue until the tool exhibits one of the following: a validation error, a significant UI lag, or a crash.
Assumptions and Uncertainty
This explanation assumes the use of UML 2.x standards. It is important to note that while the specification allows infinite nesting, implementation varies. Some tools may automatically flatten fragments or enforce hard limits (e.g., 10–20 levels) to prevent stack overflow during rendering.
Diagnostic Detail Needed: To provide a more precise limit or a tool-specific workaround, please specify which UML modeling tool and version you are currently using.