Chapter 6. Architectural Patterns

Which architectural pattern to use is a crucial tactical design decision. The right pattern will support the implementation of the system’s functional and nonfunctional requirements.

In this chapter, we will take a look at three architectural patterns and their use cases: the layered architecture, ports & adapters, and CQRS patterns.

Layered Architecture

The layered architecture pattern organizes the system’s code around the following three technical concerns:

Presentation layer

Presents/defines the user interface

Business logic layer

Implements the business logic

Data access layer

Provides access to persistence mechanisms (databases and other infrastructural components)

The layers reference each other in one direction only, as shown in Figure 6-1.

Layered architecture
Figure 6-1. Layered architecture

As you can see from the diagram, the presentation layer depends on the business logic layer, and the business logic layer depends on the data access layer.

Use Cases

The dependency between the business logic and the data access layers makes this architectural pattern a good fit for a system with its business logic implemented using the active record pattern (the patterns mentioned here were all introduced in the previous chapter).

Ports & Adapters

The ports & adapters architecture is similar to the layered architecture in that it also decomposes the system’s ...

Get What Is Domain-Driven Design? now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.