Clean Architecture: A Craftsman's Guide to Software Structure and Design
Rate it:
Open Preview
22%
Flag icon
They try to find ways to add functionality to implementations without making ch...
This highlight has been truncated due to consecutive passage length restrictions.
22%
Flag icon
Don’t refer to volatile concrete classes.
22%
Flag icon
Don’t derive from volatile concrete classes.
22%
Flag icon
Don’t override concrete functions. Concrete functions often require source code dependencies. When
23%
Flag icon
Never mention the name of anything concrete and volatile. This is really just a restatement of the principle itself.
23%
Flag icon
To comply with these rules, the creation of volatile concrete objects requires special handling. This caution is warranted because, in virtually all languages, the creation of an object requires a source code dependency on the concrete definition of that object.
23%
Flag icon
In most object-oriented languages, such as Java, we would use an Abstract Factory to manage this undesirable dependency.
23%
Flag icon
The curved line divides the system into two components: one abstract and the other concrete.
23%
Flag icon
The abstract component contains all the high-level business rules of the application.
23%
Flag icon
The concrete component contains all the implementation details that those bus...
This highlight has been truncated due to consecutive passage length restrictions.
23%
Flag icon
The way the dependencies cross that curved line in one direction, and toward more abstract entities, will become a new rule that we will call the Dependency Rule.
23%
Flag icon
If the SOLID principles tell us how to arrange the bricks into walls and rooms, then the component principles tell us how to arrange the rooms into buildings.
23%
Flag icon
Components are the units of deployment.
23%
Flag icon
They are the smallest entities that can be deployed as part of a system. In Java, they are jar files. In Ruby, they are gem files. In .Net, they are DLLs.
25%
Flag icon
These dynamically linked files, which can be plugged together at runtime, are the software components of our architectures.
25%
Flag icon
this chapter we will discuss the three principles of component cohesion:
25%
Flag icon
REP: The Reuse/Release Equivalence Principle
25%
Flag icon
CCP: The Common Closure Principle
25%
Flag icon
CRP: The Common Reuse Principle
25%
Flag icon
THE REUSE/RELEASE EQUIVALENCE PRINCIPLE The granule of reuse is the granule of release.
25%
Flag icon
We are now living in the age of software reuse—a fulfillment of one of the oldest promises of the object-oriented model.
25%
Flag icon
People who want to reuse software components cannot, and will not, do so unless those components are tracked through a release process and are given release numbers.
25%
Flag icon
Classes and modules that are grouped together into a component should be releasable together. The fact that they share the same version number and the same release tracking, and are included under the same release documentation, should make sense both to the author and to the users.
25%
Flag icon
Gather into components those classes that change for the same reasons and at the same times. Separate into different components those classes that change at different times and for different reasons.
26%
Flag icon
This is the Single Responsibility Principle restated for components.
26%
Flag icon
the Common Closure Principle (CCP) says that a component should not have mult...
This highlight has been truncated due to consecutive passage length restrictions.
26%
Flag icon
For most applications, maintainability is more important...
This highlight has been truncated due to consecutive passage length restrictions.
26%
Flag icon
If the code in an application must change, you would rather that all of the changes occur in one component, rather than being...
This highlight has been truncated due to consecutive passage length restrictions.
26%
Flag icon
two classes are so tightly bound, either physically or conceptually, that they always change together, then they belong in the same component.
26%
Flag icon
This minimizes the workload related to releasing, revalidating, and redeploying the software.
26%
Flag icon
The OCP states that classes should be closed for modification but open for extension. Because 100% closure is not attainable, closure must be strategic.
26%
Flag icon
We design our classes such that they are closed to the most common kinds of changes that we expect or have experienced.
26%
Flag icon
Gather together those things that change at the same times and for the same reasons. Separate those things that change at different times or for different reasons.
26%
Flag icon
THE COMMON REUSE PRINCIPLE Don’t force users of a component to depend on things they don’t need.
26%
Flag icon
You may have already realized that the three cohesion principles tend to fight each other.
26%
Flag icon
The REP and CCP are inclusive principles: Both tend to make components larger.
26%
Flag icon
The CRP is an exclusive principle, driving components to be smaller. It is the tension between these principles that...
This highlight has been truncated due to consecutive passage length restrictions.
26%
Flag icon
An architect who focuses on just the REP and CRP will find that too many components are impacted when simple changes are made.
26%
Flag icon
In contrast, an architect who focuses too strongly on the CCP and REP will cause too many unneeded releases to be generated.
26%
Flag icon
Generally, projects tend to start on the right hand side of the triangle, where the only sacrifice is reuse.
27%
Flag icon
We once thought that cohesion was simply the attribute that a module performs one, and only one, function.
27%
Flag icon
In choosing the classes to group together into components, we must consider the opposing forces involved in reusability and develop-ability.
27%
Flag icon
the partitioning that is appropriate today might not be appropriate next year. As a consequence, the composition of the components will likely jitter and evolve with time as the focus of the project changes from develop-ability to reusability.
27%
Flag icon
The forces that impinge upon the architecture of a component structure are technical, political, and volatile.
27%
Flag icon
Allow no cycles in the component dependency graph.
28%
Flag icon
In addition, build issues grow geometrically with the number of modules.
28%
Flag icon
is always possible to break a cycle of components and reinstate the dependency graph as a DAG. There are two primary mechanisms for doing so:
28%
Flag icon
Apply the Dependency Inversion Principle (DIP). In the case in Figure 14.3, we could create an interface that has the methods that User needs. We could then put that interface into Entities and inherit it into Authorizer. This inverts the dependency between Entities and Authorizer, thereby breaking the cycle.
28%
Flag icon
Moreover, we want to keep changes as localized as possible, so we start paying attention to the SRP and CCP and collocate classes that are likely to change together.
29%
Flag icon
As the application continues to grow, we start to become concerned about creating reusable elements. At this point, the CRP begins to influence the composition of the components.