System Design
15. Software Design PatternsAnimated walkthrough
Unit of Work Pattern
Track changes and save them together.
The idea
Collects new, changed and deleted objects and commits them in one transaction.
Watch it work
The steps light up one at a time. Use the controls to pause or step through.
- 1Begin a unit of work
- 2Track changes
- 3Commit once
- 4Roll back on error
1/4
Step by step
- 1Begin a unit of work
- 2Track changes
- 3Commit once
- 4Roll back on error
Where it is used
ORMs and transactions.
Watch out for
Long units hold memory and locks.