1. 程式人生 > >10 Common Software Architectural Patterns in a nutshell

10 Common Software Architectural Patterns in a nutshell

10 Common Software Architectural Patterns in a nutshell

Ever wondered how large enterprise scale systems are designed? Before major software development starts, we have to choose a suitable architecture that will provide us with the desired functionality and quality attributes. Hence, we should understand different architectures, before applying them to our design.

What is an Architectural Pattern?

According to Wikipedia,

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.

In this article, I will be briefly explaining the following 10 common architectural patterns with their usage, pros and cons.

  1. Layered pattern
  2. Client-server pattern
  3. Master-slave pattern
  4. Pipe-filter pattern
  5. Broker pattern
  6. Peer-to-peer pattern
  7. Event-bus pattern
  8. Model-view-controller pattern
  9. Blackboard pattern
  10. Interpreter pattern

1. Layered pattern

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

The most commonly found 4 layers of a general information system are as follows.

  • Presentation layer (also known as UI layer)
  • Application layer (also known as service layer)
  • Business logic layer (also known as domain layer)
  • Data access layer (also known as persistence layer)

Usage

  • General desktop applications.
  • E commerce web applications.
Layered pattern

2. Client-server pattern

This pattern consists of two 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.

Usage

  • Online applications such as email, document sharing and banking.
Client-server pattern

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.

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).
Master-slave pattern

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.

Usage

  • Compilers. The consecutive filters perform lexical analysis, parsing, semantic analysis, and code generation.
  • Workflows in bioinformatics.
Pipe-filter pattern

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.

Usage

Broker pattern

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

Peer-to-peer pattern

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
Event-bus pattern

8. Model-view-controller pattern

This pattern, also known as MVC pattern, divides an interactive application in to 3 parts as,

  1. model — contains the core functionality and data
  2. view — displays the information to the user (more than one view may be defined)
  3. 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.
Model-view-controller pattern

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.

Usage

  • Speech recognition
  • Vehicle identification and tracking
  • Protein structure identification
  • Sonar signals interpretation.
Blackboard pattern

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.
  • Languages used to describe communication protocols.
Interpreter pattern

Comparison of Architectural Patterns

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

相關推薦

10 Common Software Architectural Patterns in a nutshell

10 Common Software Architectural Patterns in a nutshellEver wondered how large enterprise scale systems are designed? Before major software development sta

讀書筆記: C# 7.0 in a nutshell (第 五 章 Framework Overview)

內容: 第五章 框架總覽 Overview .NET Standard 2.0 CLR 和核心框架 應用技術 1. Overview 幾乎所有 .NET 框架的作用都通過一系列的 Managed Types暴露出

Byzantine Fault Tolerance in a nutshell

Byzantine Fault Tolerance in a nutshellWhen you start to get more into blockchain, one term that you’re going to hear a lot is Byzantine Fault Tolerance.No

Political Correctness, in a nutshell

-— Autistic self-advocate and iconoclastic non-conformist, challenging the status quo —- I write about psychology, sociology, politics, history & relat

SALVIA:A Direct 3D 10 Similar Software Renderer 專案新成員招募計劃

SALVIA是一款光柵化的軟體渲染器,設計目標是達到Direct3D 10/11的核心功能的實現。我們的設計目的主要包括以下幾點: 一個高度可移植的光柵化圖形管線的軟體實現 圖形硬體工作原理的展現和教學 為下一代Many Core處理器架構的計算裝置提供高效能的圖形繪製能力 提供在GPU一類的流處理

Waymo's cars drive 10 million miles a day in a perilous virtual world

You could argue that Waymo, the self-driving subsidiary of Alphabet, has the safest autonomous cars around. It's certainly covered the most miles. But in

5 Common Anti-Patterns in React

&& — Your Frenemy…Tom & Jerry are the most iconic frenemy duo: change my mindConditional rendering is something that I use often in React, as I

Lowest Common Ancestor of Two Nodes in a Binary Tree

Reference:http://blog.csdn.net/v_july_v/article/details/18312089  http://leetcode.com/2011/07/lowest-common-ancestor-of-a-binary-tree-part-ii.html(1) Is th

10 common Array methods in JS

var arr = ["a","b","c"]; arr.push("d"); //just adds a new element into the end of an array console.l

10 Examples of How to Use Statistical Methods in a Machine Learning Project

Tweet Share Share Google Plus Statistics and machine learning are two very closely related field

poj 2559 Largest Rectangle in a Histogram 棧

hist func opc txt class sse typedef ++ limit // poj 2559 Largest Rectangle in a Histogram 棧 // // n個矩形排在一塊,不同的高度,讓你求最大的矩形的面積(矩形緊挨在一起)

[LeetCode] 237. Delete Node in a Linked List

acc oid hat pan after cal and 分享 rip Write a function to delete a node (except the tail) in a singly linked list, given only access to th

[luoguP3052] [USACO12MAR]摩天大樓裏的奶牛Cows in a Skyscraper(DP)

摩天大樓 close 技術 printf opera col cli 裏的 pen 傳送門 輸出被閹割了。 只輸出最少分的組數即可。 f 數組為結構體 f[S].cnt 表示集合 S 最少的分組數 f[S].v  表示集合 S 最少分組數下當前組所用的最少容

light oj 1094 Farthest Nodes in a Tree(樹的直徑模板)

fas problems tro tree enter have () 分享 color 1094 - Farthest Nodes in a Tree PDF (English) Statistics Forum Time Limit: 2

Constructor call must be the first statement in a constructor

nag mic tracking student cte 共存 sys 類繼承 進行 super()和this ()不能共存。否則編譯時會報異常。 Constructorcall must be the first statement in a constructo

LeetCode | Reverse Words in a String(C#)

++ style str blog cnblogs count item leetcode string 題目: Given an input string, reverse the string word by word. For example,Given s = "

[leetcode-438-Find All Anagrams in a String]

not plan english urn tco bst ice style ons Given a string s and a non-empty string p, find all the start indices of p‘s anagrams in s.Str

378. Kth Smallest Element in a Sorted Matrix

col ascend con compareto queue priority space you span Given a n x n matrix where each of the rows and columns are sorted in ascending or

[leetcode-387-First Unique Character in a String]

cnblogs store let min tps lee fin leet count Given a string, find the first non-repeating character in it and return it‘s index. If it do