Data Access Object

Intent

Object provides an abstract interface to some type of database or other persistence mechanism.

Explanation

Real world example

There's a set of customers that need to be persisted to database. Additionally we need the whole set of CRUD (create/read/update/delete) operations so we can operate on customers easily.


iluwatarArchitecturalData accessAbout 2 min
Identity Map

Intent

Ensures that each object gets loaded only once by keeping every loaded object in a map. Looks up objects using the map when referring to them.

Explanation

Real world example

We are writing a program which the user may use to find the records of a given person in a database.


iluwatarBehavioralPerformanceData accessAbout 3 min
Metadata Mapping

Intent

Holds details of object-relational mapping in the metadata.

Explanation

Real world example

Hibernate ORM Tool uses Metadata Mapping Pattern to specify the mapping between classes and tables either using XML or annotations in code.


iluwatarArchitecturalData accessAbout 2 min
Private Class Data

Intent

Private Class Data design pattern seeks to reduce exposure of attributes by limiting their visibility. It reduces the number of class attributes by encapsulating them in single Data object.

Explanation

Real world example

Imagine you are cooking a stew for your family for dinner. You want to prevent your family members from consuming the stew by tasting it while you are cooking, otherwise there will be no more stew for dinner later.


iluwatarIdiomData accessAbout 2 min
Repository

Intent

Repository layer is added between the domain and data mapping layers to isolate domain objects from details of the database access code and to minimize scattering and duplication of query code. The Repository pattern is especially useful in systems where number of domain classes is large or heavy querying is utilized.


iluwatarArchitecturalData accessAbout 2 min
Resource Acquisition Is Initialization

Intent

Resource Acquisition Is Initialization pattern can be used to implement exception safe resource management.

Class diagram

Applicability

Use the Resource Acquisition Is Initialization pattern when

  • You have resources that must be closed in every condition

iluwatarIdiomData accessLess than 1 minute
Serialized Entity Pattern

Intent

To easily persist Java objects to the database.

Explanation

Java serialization allow us to convert the object to a set of bytes. We can store these bytes into database as BLOB(binary long objects) and read them at any time and reconstruct them into Java objects.


iluwatarData accessAbout 2 min
Service Layer

Intent

Service Layer is an abstraction over domain logic. It defines application's boundary with a layer of services that establishes a set of available operations and coordinates the application's response in each operation.

Explanation

Typically applications require different kinds of interfaces to the data they store and the logic they implement. Despite their different purposes, these interfaces often need common interactions with the application to access and manipulate its data and invoke its business logic. Encoding the logic of the interactions separately in each module causes a lot of duplication. It's better to centralize building the business logic inside single Service Layer to avoid these pitfalls.


iluwatarArchitecturalData accessAbout 3 min
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.


iluwatarBehavioralData accessAbout 3 min
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.


iluwatarStructuralData accessAbout 2 min
2