10 common software architecture patterns
Have you ever thought about how to design a large enterprise system? Before deciding to start software development, the first thing is to select the appropriate architecture to guide the functional and quality attribute design of the system. Therefore, before applying software architecture to design, it is necessary to understand the common architecture patterns.
What is an architectural pattern?
Wikipedia's explanation:
In software architecture, architecture pattern is a general and reusable solution to common problems in a specific environment. The architecture pattern is very similar to the software design pattern, but the architecture pattern has a higher level and larger extension.
This article will briefly describe the concept, usage, advantages and disadvantages of 10 common architecture patterns.
1. Layered pattern
Layered mode is used to disassemble the structured software. Each level is an independent abstraction and provides services for its upper abstraction.
The system is usually divided into the following four levels:
Usage scenario
2. Client server pattern
The client / server model consists of two parts: one server and multiple clients. The server component provides services for multiple client components at the same time. The client sends a service request to the server, and the server responds to the client with the corresponding service information. In addition, the server continuously listens for requests from clients.
Online applications such as e-mail, file sharing and Banking
3. Master / slave pattern
Master / slave mode consists of two parts: master device and slave device. The master service component distributes jobs to multiple slave device components, and calculates and generates the final result according to the results fed back by these slave devices.
For database replication, the master database is recognized as the authoritative data source, and each slave database is synchronized with the master data. All devices interconnected through the bus in the computer system (including master and slave devices)
4. Pipe filter pattern
The pipeline / filter pattern is used to construct a system for generating and processing data streams. Each process is encapsulated in a filter component, and the data to be processed is delivered through a pipeline (PIPS). The pipeline is also used as buffer and synchronization between filters.
Compiler, a series of filters for lexical analysis, syntax analysis, semantic analysis and code generation bioinformatics workflow
5. Broker pattern
The agent pattern is used to decouple components in a structured system. The components in the system interact by means of remote service invocations. The broker @ h_403_161 @ component acts as the coordination role of communication between components.
The component providing the service publishes its capabilities (services and features) to the agent. The client requests the service from the agent, and the agent redirects the request to the component that has previously published the corresponding service for processing.
Usage scenario
6. Peer to peer pattern
The components in the peer-to-peer mode are called peers. Peers not only act as clients requesting services from other peers, but also act as servers responding to requests from other peers. Peers can dynamically change their roles during operation, that is, they can not only run as clients or servers, but also run as clients and servers at the same time.
Network file sharing: Gnutella and G2) streaming media protocol: P2P TV and pdtp Streaming media application: spotify
7. Event bus pattern
The event bus mode is applied to event processing and is mainly composed of four components: event source, event listener, channel and event bus. The event source publishes messages to a specific channel of the bus, the listener subscribes to the corresponding channel, and the messages published by the event source are announced to the listeners subscribing to the channel through the channel.
Android development notification service
8. Model View Controller Pattern
The model / view / controller mode (MVC mode for short) divides the interactive application into three parts:
MVC mode decouples components by separating internal information representation, user information presentation and user operation reception, so as to realize efficient code reuse.
Internet web application architecture built by mainstream development languages, web application development frameworks such as Django and rails
9. Blackboard pattern
Blackboard mode is applicable to the problem of determining the solution strategy without prediction. It is mainly composed of three components:
All components can access the blackboard. The component can write the newly generated data object to the blackboard, or obtain the specific data generated by the knowledge source from the blackboard through pattern matching.
Speech recognition structural identification of vehicle recognition and tracking proteins sonar signal analysis
10. Interpreter pattern
The parser pattern is used to design the language parser, which is mainly used to specify the code line of the evaluation program, that is, to parse the statements and expressions of a specific language. Its core idea is to define the corresponding class for each symbol of the language.
SQL and other database query language and communication protocol description language
Comparison of the above architecture modes
The following table summarizes the advantages and disadvantages of each architecture mode