Software Architecture Flashcards
Package Cohesion Principles, by Robert C. Martin:
REP – The Release Reuse Equivalency Principle
The granule of reuse is the granule of release
CCP – The Common Closure Principle
Classes that change together are packaged together
CRP – The Common Reuse Principle
Classes that are used together are packaged together
Package Coupling Principles, by Robert C. Martin:
ADP – The Acyclic Dependencies Principle
The dependency graph of packages must have no cycles
SDP – The Stable Dependencies Principle
Depend in the direction of stability
SAP – The Stable Abstractions Principle
Abstractness increases with stability
Architectural styles
The application design at the highest level of abstraction.
Tell us, in very broad strokes, how to organize our code. It’s the highest level of granularity and it specifies layers, high-level modules of the application and how those modules and layers interact with each other, the relations between them.
Architectural Patterns
Is a way to implement an Architectural Style.
A pattern is a recurring solution to a recurring problem. In the case of Architectural Patterns, they solve the problems related to the Architectural Style.
Design Patterns
A way to solve a localised problem.
Differ from Architectural Patterns in their scope, they are more localised, they have less impact on the code base, they impact a specific section of the code base.
The modern monolith
Having a monolithic Architectural Style simply means that all of the application code is deployed and run as a single process on a single node. We assume, it is using modules and components, although it is in fact often not the case.
Regarding the first one, deployed, it means that it doesn’t matter where the code is physically stored if it is organised in one or several repositories, but how it is organised at runtime. Regarding the second keyword, node, it means that it is still a monolith if we deploy the application to several servers, as in a horizontal scaling context.
In a single node server, all of the modules in a monolith are assembled to the same memory image, which is run as a single process on a single node. Communication is done through standard procedure calls through the same stack and heap. It’s the single memory image makes the application monolithic. If you are running modules in different processes, you’re doing IPC. Because modules fall into different process boundaries, you’ll start facing distributed computing challenges. That’s getting into microservice territory.
The modern monolith stops being good enough when we need:
Independent scalability of different domain components;
Different components or modules to be written in different programming languages;
Independent deployability, maybe because we have a release rate higher than the deployment pipeline can handle for one code base, causing the deployment of a release to be slow because it needs to wait for the deployment of other releases, or even causing the deployment queue to grow faster than it is consumed.
EBI.Entity
The Entity objects hold the data used by the system and all the behaviour naturally coupled to this data. Each Entity object represents a concept relevant to the problem domain and wich holds identity and resilient (persistent) data.
EBI.Boundary (Interface)
The Boundary objects model the interface with the system. Everything concerning the interface of the system is placed in an interface object.
EBI.Interactor (Control)
Behaviour that remains after the Interface objects and Entity objects have obtained their parts will be placed in the control objects.
DDD layers are…
User Interface
Responsible for drawing the screens the users use to interact with the application and translating the user’s inputs into application commands.
Application Layer
Orchestrates Domain objects to perform tasks required by the users: the Use Cases. It does not contain business logic. This layer is where the Application Services belong, as they are the containers where the use case orchestration happens.
Domain Layer
This is the layer that contains all the business logic, the Domain Services, Entities, Events and any other object type that contains Business Logic.
Infrastructure
The technical capabilities that support the layers above, ie. persistence or messaging.
Bounded context
Define a context where an isolated part of the model applies.
Anti-Corruption Layer
An anti-corruption layer is basically a middleware between two subsystems. It is used to isolate the two subsystems, making them depend on the anti-corruption layer instead of depending directly on each other.
Anti-Corruption Layer main concerns are…
Adapting subsystems APIs to what the client subsystems need;
Translating data and commands between subsystems;
Establish communication in one or several directions, as needed
Shared Kernel
In some situations, despite our desire to have completely isolated and decoupled components, it makes sense for some domain code to be shared by multiple components.
This will allow components to stay decoupled from each other, although coupled to that same shared code, the shared kernel.
Generic Subdomain
A subdomain that is not specific to our application, it could be used in any similar application.
Subdomain
A very well isolated part of the domain.
Adapters Architecture (aka Hexagonal Architecture)
Allow an application to equally be driven by users, programs, automated test or batch scripts, and to be developed and tested in isolation from its eventual run-time devices and databases.
Goal: isolate the business logic from the delivery mechanisms and tools used by the system.
Adapter
A class that transforms (adapts) an interface into another. It depends on a specific tool and a specific port (by implementing an interface).