Thứ Tư, 13 tháng 9, 2017

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 is also known as n-tier architecture pattern. It 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

  • File-sharing networks such as Gnutella and G2)
  • Multimedia protocols such as P2PTV and PDTP.
  • Proprietary multimedia applications such as Spotify.


Peer-to-peer pattern

7. Event-bus pattern

This pattern is a primarily deals with events and has 4 major components; event sourceevent listenerchannel 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. Click on the cell to view the full text within.
Comparison of Architectural Patterns

Hope you found this article useful. I would love to hear your thoughts. 😇
Thanks for reading. 😊
Cheers! 😃
(source https://medium.com/towards-data-science/10-common-software-architectural-patterns-in-a-nutshell-a0b47a1e9013)

Thứ Ba, 20 tháng 6, 2017

Setting Up CI And CD For Azure App Services With Github And Azure CLI 2.0

We are going to deploy a GitHub repo to Azure App Service and configure CI/CD for that repo through the Azure CLI 2.0 so if you’re not aware of the Azure CLI 2.0, I will request you to go to my previous blog posts here and here.
First, we will list down all the steps required for it. The steps are as follows:
Create a Resource Group
    We will create a resource group with the name githubdemorg and host it in location EASTUS
    az group create –name githubdemoorg –location EASTUS
    Azure
    Create an App Service Plan
      An App Service Plan is to define the size, location, scale count, and sku of the app where you will be hosting it.
      az appservice plan create –name githubdemplan –resource-group githubdemoorg –sku FREE
      Azure
      Create a Web App
        We will create a new web app with the following command.
        az appservice web create –name githubdemoag –resource-group githubdemorg –plan githubdemoplan
        Azure
        Create a Git repo in Github
        If you’re not familiar with github, just follow the steps.
        • Go to Github.com and Signup/login with your Credentials
        • Click on Start a project

          Azure
        • Create a new repository by passing a repo name and description and make your Repo as public. Also, make sure that you didn’t check the Initialize this repository with a README if you’re not familiar with github and blindly follow this demo.

          Azure
        Push the Code to the Github
            Go to your code directory and open a new instance of the command prompt for the git command and follow the new or existing repository on the command line according to the requirement.
            For us, we did the new repository in the demo. Let me quickly walk through the commands.
            git init
            It’s going to initiate a new blank repository in your local
            git add readme.md
            It is going to add a readme file to the repo.
            git commit –m “first commit”
            It is going to commit the code with the message in the double quote
            git remote add origin url
            It’s going to add the remote to the origin.
            git push –u origin master
            It’s going to push to origin git repo in the master branch

            Azure

            Once you completed the above commands then go to your repo on github and check if the files got pushed.

            Azure

            Deploy Code from a public Github Repository with CI &CD
            In order to set up the source control config, you need to authenticate your command line with a token, and in order to get the token you need to go to github.com and then settings and on bottom left click on personal access token.

            Azure
            Click on "Generate new token" and enter the token description.

            Azure

            Click on "Generate token" button at the bottom.
            Azure
            Copy the token generated in this step and use it in the next step. I have not used it in the screenshot below as I have already set up the token once and Azure remembers the token.
            az appservice web source-control config –name githubdemoag –resource-group githubdemorg –repo-url YOURREPOURL –branch master --git-token $token
            Azure
            Azure
            Validate CI & CD
              Now, to validate the CI CD Configuration, I am going to make a simple code change in my HTML and append Updated to GITHUB DEMO and I am going to push the code to git hub and check the site again to see if the changes are reflecting or not.
              Update the HTML File

              Azure

              Push the code to the github by using the following commands in your git cmd
              Git add .
              Git commit –m “new commit”
              Git push

              Azure
              Check the site again.

              Azure