Clean Architecture: A Craftsman's Guide to Software Structure and Design
Rate it:
Open Preview
3%
Flag icon
If you think good architecture is expensive, try bad architecture.
7%
Flag icon
Many programmers believe that is the entirety of their job. They believe their job is to make the machine implement the requirements and to fix any bugs. They are sadly mistaken.
8%
Flag icon
To fulfill its purpose, software must be soft—that is, it must be easy to change. When the stakeholders change their minds about a feature, that change should be simple and easy to make. The difficulty in making such a change should be proportional only to the scope of the change, and not to the shape of the change.
8%
Flag icon
• If you give me a program that works perfectly but is impossible to change, then it won’t work when the requirements change, and I won’t be able to make it work. Therefore the program will become useless. • If you give me a program that does not work but is easy to change, then I can make it work, and keep it working as requirements change. Therefore the program will remain continually useful.
9%
Flag icon
Structured programming imposes discipline on direct transfer of control.
9%
Flag icon
Object-oriented programming imposes discipline on indirect transfer of control.
9%
Flag icon
Functional programming imposes discipline upon assignment.
14%
Flag icon
The fact that OO languages provide safe and convenient polymorphism means that any source code dependency, no matter where it is, can be inverted.
15%
Flag icon
The question you must be asking yourself, then, is whether immutability is practicable. The answer to that question is affirmative, if you have infinite storage and infinite processor speed. Lacking those infinite resources, the answer is a bit more nuanced. Yes, immutability can be practicable, if certain compromises are made.
16%
Flag icon
Event sourcing is a strategy wherein we store the transactions, but not the state. When state is required, we simply apply all the transactions from the beginning of time.
17%
Flag icon
Historically, the SRP has been described this way: A module should have one, and only one, reason to change. Software systems are changed to satisfy users and stakeholders; those users and stakeholders are the “reason to change” that the principle is talking about. Indeed, we can rephrase the principle to say this: A module should be responsible to one, and only one, user or stakeholder.
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
Don’t force users of a component to depend on things they don’t need.
44%
Flag icon
Strictly speaking, business rules are rules or procedures that make or save the business money. Very strictly speaking, these rules would make or save the business money, irrespective of whether they were implemented on a computer. They would make or save money even if they were executed manually.
44%
Flag icon
We shall call these rules Critical Business Rules, because they are critical to the business itself, and would exist even if there were no system to automate them.
44%
Flag icon
Critical Business Rules usually require some data to work with. For example, our loan requires a loan balance, an interest rate, and a payment schedule. We shall call this data Critical Business Data. This is the data that would exist even if the system were not automated.
44%
Flag icon
The critical rules and critical data are inextricably bound, so they are a good candidate for an object. We’ll cal...
This highlight has been truncated due to consecutive passage length restrictions.
44%
Flag icon
When we create this kind of class, we are gathering together the software that implements a concept that is critical to the business, and separating it from every other concern in the automated system we are building. This class stands alone as a representative of the business. It is unsullied with concerns about databases, user interfaces, or third-party frameworks. It could serve the business in any system, irrespective of how that system was presented, or how the data was stored, or how the computers in that system were arranged. The Entity is pure business and nothing else.
46%
Flag icon
Entities encapsulate enterprise-wide Critical Business Rules. An entity can be an object with methods, or it can be a set of data structures and functions. It doesn’t matter so long as the entities can be used by many different applications in the enterprise.
46%
Flag icon
No operational change to any particular application should affect the entity layer.
46%
Flag icon
The software in the use cases layer contains application-specific business rules. It encapsulates and implements all of the use cases of the system. These use cases orchestrate the flow of data to and from the entities, and direct those entities to use their Critical Business Rules to achieve the goals of the use case.
47%
Flag icon
We also do not expect this layer to be affected by changes to externalities such as the database, the UI, or any of the common frameworks. The use cases layer is isolated from such concerns. We do, however, expect that changes to the operation of the application will affect the use cases and, therefore, the software in this layer. If the details of a use case change, then some code in this layer will certainly be affected.
47%
Flag icon
The software in the interface adapters layer is a set of adapters that convert data from the format most convenient for the use cases and entities, to the format most convenient for some external agency such as the database or the web. It is this layer, for example, that will wholly contain the MVC architecture of a GUI.
47%
Flag icon
isolated, simple data structures are passed across the boundaries. We don’t want to cheat and pass Entity objects or database rows.
47%
Flag icon
when we pass data across a boundary, it is always in the form that is most convenient for the inner circle.