- 2070 Bhadra · 4+4 marks
Forking, joining and branching in modeling
Short answer
Branching (decision/merge) maps to if/else with guarded flows. Forking splits into concurrent flows (thread start). Joining synchronizes parallel flows (thread join). These primitives directly correspond to programming constructs, enabling near one-to-one translation from activity diagrams to code.
Explain the forking, joining, and branching features available in object-oriented based modeling. How does these primitive provide the closest implementation model? Relate with any arbitrary sample.
In the UML activity diagram, a workflow is made of activities connected by transitions. The three primitives below control the flow.
Branching (decision and merge)
A branch is a diamond with one incoming flow and two or more outgoing flows, each guarded by a Boolean condition in square brackets. Exactly one outgoing flow is taken. A merge diamond brings alternative flows back together.
[ Check Stock ]
|
< in stock? >
[yes] / \ [no]
[Pack item] [Order from supplier]
\ /
(merge)
Forking
A fork is a thick bar with one incoming flow and several outgoing flows. All outgoing flows are performed concurrently (in parallel).
Joining
A join is a thick bar that has several incoming flows and one outgoing flow. The outgoing flow proceeds only when all incoming flows have arrived (synchronisation).
( Order accepted )
|
=================== fork
| |
[Pack goods] [Prepare invoice]
| |
=================== join
|
[ Dispatch ]
How they give the closest implementation model
- Branch maps directly to
if / elseandswitchstatements. - Fork maps to starting threads or processes (
new Thread(...).start()), and join tothread.join()or a barrier. - A loop is a branch whose "no" flow returns to an earlier activity (
while). - Because activity diagrams use the same constructs as programs, an activity diagram can be converted almost one to one into code.
Sample (online order): Accept order -> branch on payment valid? -> if no, send rejection; if yes, fork into "pack goods" and "prepare invoice", join, then dispatch.
if (paymentValid) {
Thread t1 = new Thread(() -> pack());
Thread t2 = new Thread(() -> invoice());
t1.start(); t2.start(); // fork
t1.join(); t2.join(); // join
dispatch();
} else { reject(); }
✓ Answer checked by Claude Opus 5.5 (high effort)
Related questions
- Object oriented system and core concepts · Object Oriented Analysis and Design, chapter 1
- Algorithmic vs object-oriented decomposition · Object Oriented Analysis and Design, chapter 1
- Structural model vs implementation model · Object Oriented Analysis and Design, chapter 1
- Conceptual, specification, implementation model classification · Object Oriented Analysis and Design, chapter 2
- Behavior modeling and four diagrams · Object Oriented Analysis and Design, chapter 2
- Domain modeling; attributes and associations guidelines · Object Oriented Analysis and Design, chapter 2
- Compare procedural and object oriented programming · Object Oriented Programming, chapter 1
- Features of microprocessor based instrumentation · Instrumentation II, chapter 1 · asked 4×
- Document Object Model with HTML/JavaScript · Web Technology, chapter 4 · asked 2×
- Manipulators available in C++ · Object Oriented Programming, chapter 8 · asked 2×
All Object Oriented Analysis and Design chapter 2 questions →