Data access

Version Number
Name / classification Version Number. Also known as Entity Versioning, Optimistic Locking. Intent Resolve concurrency conflicts when multiple clients are trying to update same entity simultaneously. Explanation Real world example Alice and Bob are working on the book, which stored in the database. Our heroes are making changes simultaneously, and we need some mechanism to prevent them from overwriting each other. In plain words Version Number pattern grants protection against concurrent updates to same entity.
Specification
Also known as Filter, Criteria Intent Specification pattern separates the statement of how to match a candidate, from the candidate object that it is matched against. As well as its usefulness in selection, it is also valuable for validation and for building to order. Explanation Real world example There is a pool of different creatures and we often need to select some subset of them. We can write our search specification such as “creatures that can fly”, “creatures heavier than 500 kilograms”, or as a combination of other search specifications, and then give it to the party that will perform the filtering.
Transaction Script
Intent Transaction Script organizes business logic by procedures where each procedure handles a single request from the presentation. Explanation Real world example You need to create a hotel room booking system. Since the requirements are quite simple we intend to use the Transaction Script pattern here. In plain words Transaction Script organizes business logic into transactions that the system needs to carry out. Programmatic example The Hotel class takes care of booking and cancelling room reservations.
Embedded Value
Also known as Aggregate Mapping, Composer Intent Many small objects make sense in an OO system that don’t make sense as tables in a database. An Embedded Value maps the values of an object to fields in the record of the object’s owner. Explanation Real-world example Examples include currency-aware money objects and date ranges. Although the default thinking is to save an object as a table, no sane person would want a table of money values.
Table Module
Intent Table Module organizes domain logic with one class per table in the database, and a single instance of a class contains the various procedures that will act on the data. Explanation Real world example When dealing with a user system, we need some operations on the user table. We can use the table module pattern in this scenario. We can create a class named UserTableModule and initialize a instance of that class to handle the business logic for all rows in the user table.