Unit of Work
Noun · Development
Definitions
A design pattern (described by Martin Fowler) that maintains a list of objects affected during a business transaction and coordinates writing out changes as a single atomic operation — tracking new, modified, and deleted entities, then flushing them to the database in the correct order within one transaction. ORMs like SQLAlchemy's Session and Entity Framework's DbContext implement this pattern.
In plain English: A pattern where you batch up all your database changes and apply them all at once in a single transaction, so either everything saves or nothing does.
Example: "SQLAlchemy's session acts as a unit of work — you add and modify objects, then call `session.commit()` and it figures out the minimal set of INSERTs and UPDATEs to execute."