软件体系架构方面英文文章翻译——软件架构基础:开发者指南
Basics of Software Architecture: A Guide for Developers
Mar 27,2023
Mastering Software Architecture: A Beginners Guide to Principles and Patterns With Examples
Software architecture is the process of designing and organizing the software components, their relationships, and how they interact with each other to achieve the desired functionality. It involves the identification of the main components of a system, their properties, and the way they interact with each other to deliver the required functionality.
Software architecture is an important process that ensures the quality of software products and helps businesses resolve complexity in the long and short term. Let’s understand it by taking a software architecture example.
Example
One example of software architecture is the design of an e-commerce website. The website consists of various components, such as the user interface, the database, and the payment gateway. The architecture of the website defines the way these components interact with each other, and the overall structure of the website. The architecture also includes the choice of technologies, tools, and frameworks used to build the website.
The importance of software architecture cannot be overstated. It plays a vital role in resolving complexity in the long and short term.
In the short term, software architecture helps in reducing development time and costs.
By defining the structure and relationships of software components, the architecture provides a roadmap for developers to follow. This makes it easier to design, develop, and test software components, resulting in faster development times and reduced costs.
In the long term, software architecture helps in maintaining the software system.
As the system evolves, it may become more complex, making it difficult to maintain and update. A well-designed software architecture provides a framework for adding new features and functionality without impacting the existing system. This ensures that the system remains flexible, scalable, and maintainable over time.
A good example of the importance of software architecture in business is the case of Amazon. Amazon is one of the largest e-commerce platforms in the world, with millions of customers and billions of transactions. The success of Amazon can be attributed in part to its software architecture. Amazon’s architecture is designed to be highly scalable, flexible, and resilient. It is built on a microservices architecture, where the various components of the system are broken down into smaller, more manageable services. This makes it easier to develop, test, and deploy new features and also makes it easier to maintain and scale the system.
Amazon’s architecture also includes various technologies and tools that enable it to handle high volumes of traffic and transactions. For instance, Amazon’s use of Amazon Web Services (AWS) provides the platform with the ability to scale up and down quickly, depending on the demand. This has allowed Amazon to handle peak traffic during the holiday season without any downtime or performance issues.
Software Architecture Principles: S.O.L.I.D.
Now that we know the basics of software architecture, let’s understand what are SOLID principles. Well, S.O.L.I.D is a set of principles that help software developers design and build software systems that are easy to maintain, extend, and test. These principles were introduced by Robert C. Martin, also known as “Uncle Bob,” and have become a standard for software development. Each letter in the acronym S.O.L.I.D stands for a principle that should be followed in software architecture design:
1. Single Responsibility Principle (SRP)
The Single Responsibility Principle states that a class should have only one responsibility or reason to change. A class that has more than one responsibility becomes difficult to maintain and test. By keeping each class focused on a single responsibility, it becomes easier to understand, change, and extend the code.
For example, consider a class that handles user authentication and also sends emails. In this case, if there is a change in the email sending functionality, it could impact the authentication functionality. Instead, separate classes should be created for user authentication and email sending, each with a single responsibility.
2. Open-Closed Principle (OCP)
The Open-Closed Principle states that a software entity should be open for extension but closed for modification. This means that the behavior of a software entity, such as a class, should be extendable without modifying its source code. The entity should be designed in a way that allows new functionality to be added without changing the existing code.
For example, consider a class that calculates the total cost of an order. If there is a new requirement to apply a discount to the order, the existing class should not be modified. Instead, a new class should be created that extends the functionality of the existing class.
3. Liskov Substitution Principle (LSP)
The Liskov Substitution Principle states that a derived class should be substitutable for its base class. This means that the derived class should be able to replace its base class without affecting the correctness of the program.
For example, consider a program that uses a base class called Shape to calculate the area of a shape. The Liskov Substitution Principle states that any derived class, such as Rectangle or Circle, should be able to replace the Shape class without breaking the program.
4. Interface Segregation Principle (ISP)
The Interface Segregation Principle states that a class should not be forced to implement interfaces it does not use. This means that interfaces should be designed to be specific to the needs of a class, rather than forcing a class to implement methods that it does not need.
For example, consider an interface called Customer that includes methods for both creating a new customer and updating an existing customer. A class that only needs to create new customers should not be forced to implement the update method. Instead, the interface should be divided into two separate interfaces, one for creating customers and one for updating customers.
5. Dependency Inversion Principle (DIP)
The Dependency Inversion Principle states that high-level modules should not depend on low-level modules. Instead, both should depend on abstractions. This means that the implementation details of a module should not be exposed to other modules.
For example, consider a program that uses a logging library. If the program directly depends on the logging library, it becomes difficult to replace the library with a different one. Instead, the program should depend on an abstraction, such as an interface, that can be implemented by any logging library. This allows the logging library to be changed without affecting the program’s functionality.

Good Software Architecture Characteristics
Good software architecture characteristics are essential for creating software systems that are efficient, scalable, maintainable, and extensible. Here are some of the most important characteristics of good software architecture:
- Modularity: The software system should be divided into modules, where each module performs a specific function. This makes it easier to develop, test, and maintain the system.
- Scalability: The software system should be designed to handle changes in requirements, data volume, and user load. This means that the system should be able to scale up or down as needed.
- Flexibility: The software system should be flexible and adaptable to change. It should be designed in a way that allows for modifications and extensions without requiring significant changes to the existing code.
- Maintainability: The software system should be easy to maintain and update. This means that the code should be well-organized, easy to understand, and easy to modify.
- Testability: The software system should be designed in a way that allows for easy testing. This means that the code should be written in a way that makes it easy to test each module individually.
- Reusability: The software system should be designed in a way that allows for code reuse. This means that modules should be designed to be used in multiple contexts and applications.
- Performance: The software system should be designed to be efficient and performant. This means that it should be able to handle a large number of users and transactions without experiencing significant slowdowns.
By incorporating these characteristics into software architecture design, developers can create software systems that are efficient, maintainable, and scalable.
Popular Software Architectural Patterns
Software architecture patterns, also known as software design patterns, are reusable solutions to common problems in software architecture. These patterns provide a framework for solving specific architectural problems and can be used to improve the quality of software design.
There are various software architecture patterns available, and each pattern provides a solution to a specific set of problems. Here are some of the most common software architecture patterns:
- Model-View-Controller (MVC): This pattern separates the user interface, business logic, and data storage into three distinct components: Model, View, and Controller. This separation improves the maintainability, scalability, and reusability of the code.
- Layered Architecture: This pattern divides the software system into logical layers, where each layer performs a specific set of functions. This separation of concerns makes it easier to develop, test, and maintain the system.
- Microservices: This pattern involves breaking down a large software system into smaller, independent services that communicate with each other through APIs. This separation improves scalability, flexibility, and fault tolerance.
- Event-Driven Architecture (EDA): This pattern involves creating systems that respond to events, such as user actions, system events, or external events. This pattern improves scalability, flexibility, and responsiveness.
- Domain-Driven Design (DDD): This pattern involves creating a software design that reflects the domain of the problem being solved. This pattern improves the maintainability, scalability, and reusability of the code.
- Repository Pattern: This pattern involves separating the data access logic from the rest of the application code. This pattern improves the testability, maintainability, and extensibility of the code.
By using software architecture patterns, developers can create software systems that are more efficient, scalable, and maintainable. These patterns provide a framework for solving specific architectural problems, and can be used to improve the quality of software design. If you want to quickly learn about all major software architecture patterns used in major industries, here’s a video that could help.
Conclusion
In conclusion, we should acknowledge software architecture as a critical process that ensures the quality and maintainability of software products. It plays a vital role in resolving complexity in the long and short term, by providing a framework for designing, developing, testing, and maintaining software systems.
The example of Amazon demonstrates the importance of software architecture in business, by providing a scalable, flexible, and resilient platform for e-commerce transactions. A well-designed software architecture is essential for businesses looking to develop and maintain high-quality software products that meet the demands of today’s customers.
Lastly, as a developer, it’s crucial to stay updated with the latest technological advancements. Here are the top software architecture trends to keep an eye on in 2023 and beyond.
软件架构基础:开发者指南
2023年3月27日
掌握软件架构:初学者指南与示例
软件架构是设计和组织软件组件、它们之间的关系以及它们如何相互作用以实现所需功能的过程。它涉及识别系统的主要组件、它们的属性以及它们如何相互作用以提供所需功能。
软件架构是一个重要的过程,它确保软件产品的质量,并帮助企业在长期和短期内解决复杂性。让我们通过一个软件架构的例子来理解它。
示例
软件架构的一个例子是电子商务网站的设计。该网站由各种组件组成,例如用户界面、数据库和支付网关。网站的架构定义了这些组件如何相互作用,以及网站的整体结构。架构还包括用于构建网站的技术、工具和框架的选择。
软件架构的重要性不言而喻。它在长期和短期内解决复杂性方面起着至关重要的作用。
在短期内,软件架构有助于减少开发时间和成本。
通过定义软件组件的结构和关系,架构为开发人员提供了遵循的路线图。这使得设计、开发和测试软件组件变得更加容易,从而缩短开发时间并降低成本。
从长远来看,软件架构有助于维护软件系统。
随着系统的发展,它可能会变得更加复杂,使得维护和更新变得困难。一个设计良好的软件架构为添加新功能和特性提供了框架,而不会影响现有系统。这确保了系统随着时间的推移保持灵活、可扩展和可维护性。
一个关于软件架构在业务中的重要性的好例子是[亚马逊](https://www.amazon.in/)的案例。亚马逊是世界上最大的电子商务平台之一,拥有数百万客户和数十亿笔交易。亚马逊的成功部分归功于其软件架构。亚马逊的架构设计为高度可扩展、灵活和具有弹性。它基于微服务架构,系统的各个组件被分解为更小、更易管理的服务。这使得开发、测试和部署新功能变得更加容易,也使得维护和扩展系统变得更加容易。
亚马逊的架构还包括各种技术和工具,使其能够处理高流量和高交易量。例如,亚马逊使用[亚马逊网络服务(AWS)](https://aws.amazon.com/)为平台提供了根据需求快速扩展的能力。这使得亚马逊能够在假日季节处理高峰流量,而不会出现停机或性能问题。
软件架构原则:S.O.L.I.D.
现在我们已经了解了软件架构的基础知识,让我们来了解一下什么是SOLID原则。S.O.L.I.D是一组帮助软件开发者设计和构建易于维护、扩展和测试的软件系统的原则。这些原则由Robert C. Martin(也称为“Uncle Bob”)提出,并已成为软件开发的标准。S.O.L.I.D中的每个字母代表一个在软件架构设计中应遵循的原则:
1. 单一职责原则(SRP)
单一职责原则指出,一个类应该只有一个职责或一个变更的原因。一个具有多个职责的类会变得难以维护和测试。通过让每个类专注于单一职责,代码变得更易于理解、更改和扩展。
例如,考虑一个处理用户身份验证并发送电子邮件的类。在这种情况下,如果电子邮件发送功能发生变化,可能会影响身份验证功能。相反,应该为用户身份验证和电子邮件发送创建单独的类,每个类都有一个单一的职责。
2. 开闭原则(OCP)
开闭原则指出,软件实体应该对扩展开放,但对修改关闭。这意味着软件实体(如类)的行为应该是可扩展的,而不需要修改其源代码。实体应该以允许在不更改现有代码的情况下添加新功能的方式进行设计。
例如,考虑一个计算订单总成本的类。如果有一个新的需求要为订单应用折扣,则不应修改现有的类。相反,应该创建一个新类来扩展现有类的功能。
3. 里氏替换原则(LSP)
里氏替换原则指出,派生类应该可以替换其基类。这意味着派生类应该能够替换其基类,而不会影响程序的正确性。
例如,考虑一个使用名为Shape的基类来计算形状面积的程序。里氏替换原则指出,任何派生类(如Rectangle或Circle)都应该能够替换Shape类,而不会破坏程序。
4. 接口隔离原则(ISP)
接口隔离原则指出,类不应该被迫实现它不使用的接口。这意味着接口应该设计为特定于类的需求,而不是强迫类实现它不需要的方法。
例如,考虑一个名为Customer的接口,它包括创建新客户和更新现有客户的方法。一个只需要创建新客户的类不应该被迫实现更新方法。相反,接口应该分为两个单独的接口,一个用于创建客户,另一个用于更新客户。
5. 依赖倒置原则(DIP)
依赖倒置原则指出,高层模块不应该依赖于低层模块。相反,两者都应该依赖于抽象。这意味着模块的实现细节不应该暴露给其他模块。
例如,考虑一个使用日志库的程序。如果程序直接依赖于日志库,则很难用不同的库替换它。相反,程序应该依赖于一个抽象(如接口),该抽象可以由任何日志库实现。这允许在不影响程序功能的情况下更改日志库。

良好软件架构的特征
良好的软件架构特征对于创建高效、可扩展、可维护和可扩展的软件系统至关重要。以下是一些良好软件架构的最重要特征:
1. 模块化:软件系统应分为模块,每个模块执行特定功能。这使得开发、测试和维护系统变得更加容易。
2. 可扩展性:软件系统应设计为能够处理需求、数据量和用户负载的变化。这意味着系统应该能够根据需要扩展或缩小。
3. 灵活性:软件系统应具有灵活性和适应性。它应该以允许在不显著更改现有代码的情况下进行修改和扩展的方式进行设计。
4. 可维护性:软件系统应易于维护和更新。这意味着代码应组织良好、易于理解和修改。
5. 可测试性:软件系统应设计为易于测试。这意味着代码应以易于单独测试每个模块的方式编写。
6. 可重用性:软件系统应设计为允许代码重用。这意味着模块应设计为可在多种上下文和应用程序中使用。
7. 性能:软件系统应设计为高效和高性能。这意味着它应该能够处理大量用户和交易,而不会出现显著的减速。
通过将这些特征纳入软件架构设计,开发人员可以创建高效、可维护和可扩展的软件系统。
流行的软件架构模式
软件架构模式,也称为软件设计模式,是解决软件架构中常见问题的可重用解决方案。这些模式为解决特定架构问题提供了框架,并可用于提高软件设计的质量。
有各种软件架构模式可用,每种模式都为特定问题集提供解决方案。以下是一些最常见的软件架构模式:
1. 模型-视图-控制器(MVC):该模式将用户界面、业务逻辑和数据存储分为三个不同的组件:模型、视图和控制器。这种分离提高了代码的可维护性、可扩展性和可重用性。
2. 分层架构:该模式将软件系统分为逻辑层,每层执行一组特定功能。这种关注点分离使得开发、测试和维护系统变得更加容易。
3. 微服务:该模式涉及将大型软件系统分解为通过API相互通信的较小、独立的服务。这种分离提高了可扩展性、灵活性和容错性。
4. 事件驱动架构(EDA):该模式涉及创建响应事件(如用户操作、系统事件或外部事件)的系统。这种模式提高了可扩展性、灵活性和响应性。
5. 领域驱动设计(DDD):该模式涉及创建反映所解决问题的领域的软件设计。这种模式提高了代码的可维护性、可扩展性和可重用性。
6. 仓库模式:该模式涉及将数据访问逻辑与应用程序代码的其余部分分离。这种模式提高了代码的可测试性、可维护性和可扩展性。
通过使用软件架构模式,开发人员可以创建更高效、可扩展和可维护的软件系统。这些模式为解决特定架构问题提供了框架,并可用于提高软件设计的质量。如果你想快速了解主要行业中使用的所有主要软件架构模式,这里有一个视频可能会有所帮助。
结论
总之,我们应该承认软件架构是确保软件产品质量和可维护性的关键过程。它在长期和短期内解决复杂性方面起着至关重要的作用,通过为设计、开发、测试和维护软件系统提供框架。
亚马逊的例子展示了软件架构在业务中的重要性,通过为电子商务交易提供可扩展、灵活和具有弹性的平台。一个设计良好的软件架构对于希望开发和维护高质量软件产品的企业至关重要,这些产品能够满足当今客户的需求。
最后,作为开发人员,及时了解最新的技术进步至关重要。

浙公网安备 33010602011771号