Clean Architecture (Chinese Translation)

repository·master·Indexed 21 days ago

https://github.com/leewaiho/clean-architecture-zh

A Chinese translation of the book 'Clean Architecture', implemented using VuePress. The content covers software design and architecture across six main parts: overview, programming paradigms, SOLID design principles (SRP, OCP, LSP, ISP, DIP), component building principles, software architecture patterns, and implementation details regarding databases, Web, and frameworks.

Tokens
45.2K
Snippets
20
Records
217
Agent score
75%

What's inside leewaiho-clean-architecture-zh

  1. Summary of Component Coupling and Dependency Management

    master
    Chapter 14 focuses on managing component coupling through dependency metrics. These metrics are used to measure how closely a system design conforms to a 'good' pattern of dependency and abstraction. While metrics are imperfect and represent measurements against an arbitrary standard rather than absolute truth, they serve as tools to identify whether dependencies between components are beneficial or detrimental to the architecture.
  2. Explore the Clean Architecture Chinese translation content

    master

    This repository provides a Chinese translation of the 'Clean Architecture' book. The content is organized into six main parts covering the following topics:

    1. Overview (第一部分 概述): Introduction to design and architecture.
    2. Programming Paradigms (第二部分 从基础构件开始:编程范式): Structured programming, Object-Oriented Programming (OOP), and Functional Programming.
    3. Design Principles (第三部分 设计原则): SOLID principles including SRP (Single Responsibility), OCP (Open-Closed), LSP (Liskov Substitution), ISP (Interface Segregation), and DIP (Dependency Inversion).
    4. Component Building Principles (第四部分 组件构建原则): Components, component aggregation, and component coupling.
    5. Software Architecture (第五部分 软件架构): Independence, boundaries, policy and layers, business logic, Clean Architecture patterns, and testing boundaries.
    6. Implementation Details (第六部分 实现细节): Treating databases, Web, and application frameworks as implementation details.
  3. What is an Entity in Clean Architecture?

    master

    An Entity is a software object (or module) that embodies a small set of Critical Business Rules operating on Critical Business Data.

    Characteristics of an Entity:

    • Encapsulation: The Entity either contains the Critical Business Data or has very easy access to it.
    • Interface: The interface of an Entity consists of the functions that implement the Critical Business Rules.
    • Independence: An Entity is "pure business." It must be unsullied by concerns regarding databases, user interfaces, or third-party frameworks. It should be able to serve the business in any system, regardless of how data is stored or how the UI is presented.
    • Implementation Agnostic: While often implemented as a class in object-oriented languages, an Entity can be any single, separate software module that binds critical data and rules together.
  4. What is Screaming Architecture?

    master

    Screaming Architecture is a design principle where the high-level structure of a software system (its top-level directories and packages) clearly communicates the system's core business purpose or use cases, rather than the technical tools or frameworks used to implement it.

    Instead of a directory structure that screams "Rails," "Spring," or "ASP," a well-designed architecture should scream "Health Care System," "Accounting System," or "Inventory Management System."

  5. What is software architecture?

    master

    Software architecture is the shape given to a system by its builders. This shape is defined by:

    1. The division of the system into components.
    2. The arrangement of those components.
    3. The ways in which those components communicate.

    The primary purpose of architecture is not just to make a system work (which is a passive/cosmetic role), but to support the system's entire lifecycle. Good architecture aims to minimize the lifetime cost of the system and maximize programmer productivity by making the system easy to understand, develop, maintain, and deploy.

  6. Overview of SOLID Design Principles

    master

    The SOLID principles are mid-level design principles used to organize functions and data structures (referred to as "classes") into modules and components. The primary goals of applying these principles are to create software structures that:

    • Tolerate change: Make the system resilient to modifications.
    • Are easy to understand: Improve code readability and maintainability.
    • Enable component reuse: Build components that can be used across multiple software systems.

    While often associated with Object-Oriented Programming (OOP), these principles apply to any grouping of functions and data, regardless of whether they are explicitly defined as "classes."

  7. Overview of Programming Paradigms

    master
    This chapter provides a high-level overview of the three primary programming paradigms that form the foundation of software architecture: Structured Programming, Object-Oriented Programming, and Functional Programming. Each paradigm is characterized by the specific type of discipline or restriction it imposes on the programmer to improve program structure and reliability.
  8. Summary of Clean Embedded Architecture principles

    master

    To ensure the long-term health and maintainability of an embedded product, avoid the following anti-patterns:

    1. Treating all code as firmware: Do not allow all application logic to be tightly coupled to the hardware/firmware layer.
    2. Hardware-only testing: Avoid architectures where code can only be tested on the target hardware. This makes the development process difficult and slow.

    A clean embedded architecture separates concerns to allow for better testing (e.g., off-target testing) and long-term maintenance.

  9. Understand Plugin Architecture for Scalability

    master

    A plugin architecture is a pattern used to create scalable and maintainable systems by separating core business rules from optional or highly variable components. In this model, components like the User Interface (GUI) and the Database are treated as 'plugins' that plug into the core business rules.

    Key Characteristics:

    • Independence: Core business rules remain independent of the components that implement them.
    • Interchangeability: Because the GUI is a plugin, you can switch between Web-based, Client/Server, SOA, or Console-based interfaces. Because the Database is a plugin, you can swap SQL databases for NoSQL or file-system-based databases.
    • Isolation: Changes in a plugin (e.g., changing a web page format or a database schema) should not affect or break the core business rules.
  10. Design a Screaming Architecture

    master

    A 'Screaming Architecture' is a design principle where the architecture of a system clearly communicates its purpose and business domain (its use cases) rather than the technical tools or frameworks used to implement it.

    When designing your system:

    1. Prioritize Use Cases: The structure of your code should immediately signal what the system does (e.g., a healthcare system, a banking system) rather than what technology it uses (e.g., a Spring Boot app, a React app).
    2. Decouple from Frameworks: Frameworks, controllers, and views should be treated as implementation details. A developer looking at the repository should be able to understand the core business logic without being distracted by the delivery mechanism.
    3. Delay Detail Decisions: If asked about specific UI or web components (like Views or Controllers), treat them as details that can be decided later, ensuring the core domain remains the focus.
  11. The C4 Software Architecture Model: Containers, Components, and Classes

    master

    The C4 model provides a hierarchical way to think about the static structure of a software system. It breaks the system down into four levels (though this text focuses on the three lower levels):

    1. Containers: The highest level of deployment. Examples include Web applications, mobile apps, standalone applications, databases, or file systems.
    2. Components: Reside inside a container. A component is defined as "a grouping of related functionality behind a nice clean interface."
    3. Classes (or Code): The smallest unit, which implements the components.

    Note: Whether a component resides in a separate deployment unit (like a Java .jar file) is considered an orthogonal concern to its structural definition in the C4 model.

  12. How to split data streams using hierarchical policies

    master

    Data streams can be split by separating different levels of policy. Instead of one monolithic component handling everything, you can divide logic into:

    1. Lower-level mechanics policies: These handle the fundamental rules of the system (e.g., how a player moves through a map, how caverns are connected, and triggering raw events like FoundFood or FellInPit).
    2. Higher-level policies: These manage the consequences and state (e.g., player health, winning/losing conditions). They consume the events declared by the lower-level mechanics to update the global state.

    This separation allows for a cleaner flow where low-level components declare events and high-level components manage the resulting state.