Pages

Showing posts with label Pattern. Show all posts
Showing posts with label Pattern. Show all posts

Monday

Top 10 common Software Architectural Patterns



Introduction:


Did you ever posed the question:  How large software in industrial scale systems are designed ?

Here I'll explain to you the most 10 common software architectural patterns one by one.

Before beginning the software development, we have to understand the requirement, then we have to choose a suitable architecture that will provide us the desired functionality and quality attributes.

What is the meaning of Architectural Pattern and why it's a very essential step ?

An architectural pattern is a general, reusable solution to a commonly occurring problem in software architecture within a given context. Architectural patterns are similar to software design pattern but have a broader scope.


1. Layered pattern:

This pattern can be used to structure programs that can be decomposed into groups of subtasks, each of them is at a particular level of abstraction. Each layer provides services to the next higher layer.

Layered pattern

As you can see in figure 'Layered pattern' The most commonly found 4 layers of a general information system are :

  1. Presentation layer (also known as UI layer)
  2. Application layer (also known as service layer)
  3. Business logic layer (also known as domain layer)
  4. Data access layer (also known as persistence layer)

The power of the layered architecture pattern is the separation of concerns among components which means that components within a specific layer deal only with logic that pertains to that layer.
This type of component classification makes it easy to build ,effective roles and responsibility models into your architecture, and also makes it easy to develop, test, govern, and maintain applications using this architecture pattern due to well-defined component interfaces and limited component scope.

The layered pattern architectures have been around since the beginning of digital computers (since the early 1960s), There is many examples of using this pattern in the systems you use every day, let's take for example the famous OSI seven-layer model that facilitates communication between computers. Here each layer provides a higher level of functionality than the layer below it



OSI model



2-Client-server pattern:

This pattern consists of two principal parties :a Server and multiple Clients.
The server component will provide services to multiple client components. Clients request services from the server and the server provides relevant services to those clients. Furthermore, the server continues to listen to client requests.
The most usage of this pattern is online applications such as email, document sharing and banking.

Client Server model


3-Master-slave pattern:

This pattern consists of two parties; master and slaves. The master component distributes the work among identical slave components, and computes a final result from the results which the slaves return.This pattern is often used for multi-threaded applications in which many instances of the same problem must be solved. (Travelling Salesman Problem, for example.) The master creates and launches slaves to solve these instances in "parallel". When all of the slaves have finished, the master harvests the results.
Master-Slave pattern is also used for user interfaces and servers. In both cases the master listens for commands coming either from the user or from clients. When a command is received, a slave is launched to execute the command while the master resumes listening for more commands (such as the "suspend the last command" command.)


Usage:
  • In database replication, the master database is regarded as the authoritative source, and the slave databases are synchronized to it. 
  • Peripherals connected to a bus in a computer system (master and slave drives).




4-Pipe-filter pattern:

This pattern can be used to structure systems which produce and process a stream of data. Each processing step is enclosed within a filter component. Data to be processed is passed through pipes. These pipes can be used for buffering or for synchronization purposes.
We use the Pipes and Filters architectural style to divide a larger processing task into a sequence of smaller, independent processing steps (Filters) that are connected by channels (Pipes).




In this pattern, a single event triggers a sequence of processing steps, each performing a specific function. For example, let's assume a new order arrives in our enterprise in the form of a message. One requirement may be that the message is encrypted to prevent eavesdroppers from spying on a customer's order. A second requirement is that the messages contain authentication information in the form of a digital certificate to ensure that orders are placed only by trusted customers. In addition, duplicate messages could be sent from external parties (remember all the warnings on the popular shopping sites to click the 'Order Now' button only once?). To avoid duplicate shipments and unhappy customers, we need to eliminate duplicate messages before subsequent order processing steps are initiated. To meet these requirements, we need to transform a stream of possibly duplicated, encrypted messages containing extra authentication data into a stream of unique, simple plain-text order messages without the extraneous data fields.

Usage:
  • Compilers. The consecutive filters perform lexical analysis, parsing, semantic analysis, and code generation.
  • Workflows in bioinformatics

5-Broker pattern:

This pattern is used to structure distributed systems with decoupled components. These components can interact with each other by remote service invocations. A broker component is responsible for the coordination of communication among components. Servers publish their capabilities (services and characteristics) to a broker.
Clients request a service from the broker, and the broker then redirects the client to a suitable service from its registry.

Broker pattern

Usage:
Message broker software such as Apache ActiveMQ, Apache Kafka, RabbitMQ and JBoss Messaging.


6-Peer-to-peer pattern:

In this pattern, individual components are known as peers. Peers may function both as a client, requesting services from other peers, and as a server, providing services to other peers. A peer may act as a client or as a server or as both, and it can change its role dynamically with time.


Usage: 
  • File-sharing networks such as Gnutella and G2) 
  • Multimedia protocols such as P2PTV and PDTP.

7-Event-bus pattern:

This pattern primarily deals with events and has 4 major components; event source, event listener, channel and event bus. Sources publish messages to particular channels on an event bus. Listeners subscribe to particular channels. Listeners are notified of messages that are published to a channel to which they have subscribed before.



Usage:
  • Android development 
  • Notification services
  • Dbus communication
8-Model-view-controller pattern

This pattern, also known as MVC pattern, divides an interactive application in to 3 parts as, 
  • Model: Contains the core functionality and data 
  • View:  Displays the information to the user (more than one view may be defined) 
  • Controller: Handles the input from the user. This is done to separate internal representations of information from the ways information is presented to, and accepted from, the user. It decouples components and allows efficient code reuse.


Usage:

  • Architecture for World Wide Web applications in major programming languages. 
  • Web frameworks such as Django and Rails.

9. Blackboard pattern:

This pattern is useful for problems for which no deterministic solution strategies are known. The blackboard pattern consists of 3 main components.

  • blackboard: a structured global memory containing objects from the solution space knowledge 
  • source: specialized modules with their own representation control 
  • component: selects, configures and executes modules.
All the components have access to the blackboard. Components may produce new data objects that are added to the blackboard. Components look for particular kinds of data on the blackboard, and may find these by pattern matching with the existing knowledge source.


The blackboard pattern provides effective solutions for designing and implementing complex systems where heterogeneous modules have to be dynamically combined to solve a problem. This provides non-functional properties such as:
  • Reusability
  • Changeability
  • Robustness.
The blackboard pattern allows multiple processes to work closer together on separate threads, polling and reacting when necessary.

Usage:
  • speech recognition
  • vehicle identification and tracking
  • protein structure identification
  • sonar signals interpretation.

10. Interpreter pattern

This pattern is used for designing a component that interprets programs written in a dedicated language. It mainly specifies how to evaluate lines of programs, known as sentences or expressions written in a particular language. The basic idea is to have a class for each symbol of the language. 



Usage:

Database query languages such as SQL parsing, symbol processing engine and languages used to describe communication protocols.


Comparison of Architectural Patterns :

The table given below summarizes the pros and cons of each architectural pattern:
































































































Top 10 common Software Architectural Patterns

Introduction: Did you ever posed the question:  How large software in industrial scale systems are designed ? Here I'll explai...