Common software architecture patterns: layered architecture pattern, client-server pattern, master-slave pattern, pipeline-filter pattern, proxy pattern, point-to-point pattern, event bus pattern, model-view-controller ( MVC) mode, blackboard mode, interpreter mode, etc.
10 common software architecture patterns
#Want to know what large enterprise-level systems are? How was it designed? Before the main body of software is developed, we must choose a suitable architecture to provide the required functionality and quality characteristics. So we should understand the different architectures before applying them to the design.
What is architectural pattern
Wikipedia:Architectural pattern is A common, reusable solution to a commonly occurring problem within a given context of software architecture. Architectural patterns are similar to software design patterns, but broader in scope.
In this article, I will briefly explain the applications, advantages and disadvantages of the following 10 common architectural patterns.
1. Layered mode
2. Client-server mode
3. Master-slave mode
4. Pipe-filter mode
5. Proxy mode
6. Point-to-point mode
7. Event bus mode
8. Model-view-controller mode
9. Blackboard mode
10. Interpreter mode
1. Hierarchical pattern
This pattern is used to build programs that can be decomposed into multiple groups of subtasks. Each subtask is in a certain abstraction layer, and each layer is The service is provided by the previous higher level. The most common 4-layer system in general information systems is as follows.
##2. Client-server mode
This mode consists of two Partial composition: single server and multiple clients. A server component provides services to multiple client components. Clients request services from the server, and the server provides corresponding services to these clients. Additionally, the server continues to listen for client requests.Application scenarios
3. Master-slave mode
This mode consists of two parts: the master node and multiple slave nodes. The master node component dispatches tasks to multiple independent slave node components and calculates the final result based on the results returned by the slave nodes.Application scenario
##4. Pipe-filter mode This pattern is used to build systems that produce and process data streams. Each processing step is encapsulated in a filter component. The data to be processed is sent to pipes, which can be used for buffering or synchronization.
Compiler, successive filters perform word semantic analysis, syntax analysis, semantic analysis and code generation
5. Agent mode This pattern is used to build distributed systems with decoupled components. These components interact with each other through remote calls. The proxy component is responsible for the communication coordination of multiple components. The server exposes their capabilities (services and features) to the proxy; the client obtains the service from the proxy, and then the proxy redirects the client to an appropriate service in the registered service library.
Message queue software, such as Apache ActiveMQ, Apache Kafka, RabbitMQ and JBoss Messaging
6. Point-to-point mode
In this mode, each independent component is called a peer. Peers can either act as clients to obtain services from other peers, or act as servers to provide services to other peers. Peers can act as clients, servers, or both, and dynamically switch roles at any time.
Application Scenario
##7. Event bus mode
This mode mainly handles events and has 4 main components: event source, event listener, channel and event bus. The event source publishes messages to a channel on the event bus, and the listener subscribes to a channel and learns about messages published in the subscribed channel.Application Scenario
8. Model-View-Controller Pattern
This pattern is also called the MVC pattern. It divides the interactive program into three parts: Model - Contains core functionality and data, View - displays information to the user (multiple views can be defined), Controller - handles user input. It does this by splitting the internal representation of user information from the way it is presented and received, decoupling components and allowing efficient code reuse.Application scenarios
9. Blackboard mode
This mode is very suitable for problems where there is no deterministic solution strategy. it works. The blackboard pattern consists of three main components, the blackboard - a structured global memory containing solution space objects, the knowledge source - a specialized module with its own representation, and the control component - the selection, configuration and execution module. All components have access to the blackboard and new data objects can be generated and added to the blackboard. In Blackboard, certain types of data can be found based on matching rules from existing knowledge sources.Application scenarios
10. Interpreter Mode
This pattern is used for designing components that interpret programs written in a specific language. This component mainly specifies how to evaluate lines of program code, which are so-called statements or expressions written in a certain language. The basic point is to classify language symbols.Application scenarios
Architectural Pattern Comparison
The following table outlines the pros and cons of each architectural pattern.The above is the detailed content of What are some common software architectures?. For more information, please follow other related articles on the PHP Chinese website!