10 Common Software Architectural Patterns: Part 2blog
We continue to analyse the top 10 software architecture patterns, which can be applied for various needs. Here are five more common patterns, which might be suitable for your goals. To learn about the first five examples, read part 1 of this text.
Pattern #6: Peer-to-peer (P2P)
“Peer-to-peer (P2P) pattern” is markedly different from the client-server pattern since each computer on the network has the same authority. Key characteristics of the P2P pattern are as follows:
- There isn’t one central server, with each node having equal capabilities.
- Each computer can function as a client or a server.
- When more computers join the network, the overall capacity of the network increases.
File-sharing networks are good examples of the P2P pattern. Bitcoin and other cryptocurrency networks are other examples. Advantages of a P2P network are as follows:
- P2P networks are decentralized, therefore, they are more secure. You must have already heard a lot about the security of the Bitcoin network.
- Hackers can’t destroy the network by compromising just one server.
Under heavy load, the P2P pattern has performance limitations, as the questions surrounding the Bitcoin transaction throughout shows.
Pattern #7: Event-bus pattern
There are applications when components act only when there is data to be processed. At other times, these components are inactive. “Event-bus pattern” works well for these, and it has the following characteristics:
- A central agent, which is an event-bus, accepts the input.
- Different components handle different functions, therefore, the event-bus routes the data to the appropriate module.
- Modules that don’t receive any data pertaining to their function will remain inactive.
- This pattern helps developers handle complexity.
- It’s a scalable architecture pattern.
- This is an extensible architecture, new functionalities will only require a new type of events.
This software architecture pattern is also used in Android development.
Some disadvantages of this pattern are as follows:
- Testing of interdependent components is an elaborate process.
- If different components handle the same event require complex treatment to error-handling.
- Some amount of messaging overhead is typical of this pattern.
The development team should make provision for sufficient fall-back options in the event the event-bus has a failure.
Pattern #8: Model-View-Controller (MVC)
“Model-View-Controller (MVC) architecture pattern” involves separating an applications’ data model, presentation layer, and control aspects. Following are its’ characteristics:
- There are three building blocks here, namely, model, view, and controller.
- The application data resides in the model.
- Users see the application data through the view, however, the view can’t influence what the user will do with the data.
- The controller is the building block between the model and the view. View triggers events, subsequently, the controller acts on it. The action is typically a method call to the model. The response is shown in the view.
This pattern is popular. Many web frameworks like Spring and Rails use it, therefore, many web applications utilize this pattern. Its’ advantages are as follows:
- Using this model expedites the development.
- Development teams can present multiple views to users.
- Changes to the UI is common in web applications, however, the MVC pattern doesn’t need changes for it.
- The model doesn’t format data before presenting to users, therefore, you can use this pattern with any interface.
There are also a few disadvantages, for e.g.:
- With this pattern, the code has new layers, making it harder to navigate the code.
- There is typically a learning curve for this pattern, and developers need to know multiple technologies.
Pattern #9: Blackboard
Emerging from the world of ‘Artificial Intelligence’ (AI) development, the “Blackboard architecture pattern” is more of a stop-gap arrangement. Its’ noticeable characteristics are as follows:
- When you deal with an emerging domain like AI or ‘Machine Learning’ (ML), you don’t necessarily have a settled architecture pattern to use. You start with the blackboard pattern, subsequently, when the domain matures, you adopt a different architecture pattern.
- There are three components, namely, the blackboard, a collection of knowledge resources, and a controller.
- The application system stores the relevant information in the blackboard.
- The knowledge resources could be algorithms in the AI or ML context that collect information and updates the blackboard.
- The controller reads from the blackboard and updates the application ‘assets’, for e.g., robots.
Image recognition, speech recognition, etc. use this architecture pattern. It has a few advantages, as follows:
- The pattern facilitates experiments.
- You can reuse the knowledge resources like algorithms.
There are also limitations, for e.g.:
- It’s an intermediate arrangement. Ultimately, you will need to arrive at a suitable architecture pattern, however, you don’t have certainty that you will find the right answer.
- All communication within the system happens via the blackboard, therefore, the application can’t handle parallel processing.
- Testing can be hard.
Pattern #10: Interpreter
A pattern specific to certain use cases, the “Interpreter pattern” deals with the grammar of programming languages. It offers an interpreter for the language. It works as follows:
- You implement an interface that aids in interpreting given contexts in a programming language.
- The pattern uses a hierarchy of expressions.
- It also uses a tree structure, which contains the expressions.
- A parser, external to the pattern, generates the tree structure for evaluating the expressions.
The use of this pattern is in creating “Classes” from symbols in programming languages. You create a grammar for the language, so that interpretation of sentences becomes possible. Network protocol languages and SQL uses this pattern.
Evaluating software architecture patterns for your strategic application?
Are you trying to find the best software architecture pattern for your key application? You need to make the right choice first time, however, you need qualified software architects for that. It’s a hot skill. You might need professional.