Friday 29 November 2019

Top 10 programming architectural patterns with their usage, pros and cons.

Top 10 programming architectural patterns with their usage, pros and cons.
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
  1. General desktop applications.
  2. E commerce web applications.

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
  1. Online applications such as email, document sharing and banking.

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
  1. In database replication, the master database is regarded as the
    authoritative source, and the slave databases are synchronized to it.
  2. 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.
Usage
  1. Compilers. The consecutive filters perform lexical analysis, parsing, semantic analysis, and code generation.
  2. 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.
Usage
  1. 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
  1. File-sharing networks such as Gnutella and G2)
  2. Multimedia protocols such as P2PTV and PDTP.
  3. Proprietary multimedia applications such as Spotify.

7. Event-bus pattern
This pattern is a 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
  1. Android development
  2. Notification services

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
  1. Architecture for World Wide Web applications in major programming languages.
  2. 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.
Usage
  1. Speech recognition
  2. Vehicle identification and tracking
  3. Protein structure identification
  4. 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
  1. Database query languages such as SQL.
  2. Languages used to describe communication protocols.

Difference between design pattern and architecture pattern

In Simple English way
Both are synonym to design. Architecture is usually used for technical aspect of design. Architecture in day to day lang is used for building design too. But its way complex than just a word. In easy words, you can say architecture is buildind design and design is product of smaller objects like interior and furniture.

or
The terms are related but only one is also the other. Architects are designers... but designers are not necessarily architects. Architects work in the medium of structure, and sometimes sculpture, but must balance art with science, for two main purposes: 1) protecting people's lives, especially in the case of emergency, i.e. a building fire AND 2) fachieving design criteria such as how to provide bodily comfort when there is a cold outside temperature, or collect water from a rooftop and lavatories for use later, or various other useful science-driven pursuits...

In Simple Technical english way
Design pattern are basically the solution to recurring problem with respect to OOPs world.we have problem and have its proposed solution.eg.factory pattern,singleton pattern etc.
Architecture is about how your code is structured like organisation of Libraries,components or any other thing that needed.MVC,MVP,MVVM are examples of architecture.
-------------------------------
A system can have multiple levels and scope:
  1. Function- implementation of a functiom
  2. Class- impelementation of a class
  3. Project- relations between classes
  4. Solution- relations between projects
  5. System- relations between solutions
Design patterns target the first 3 scopes. It helps to have a better structure and maintainability.
Architecture is the highest level design of a solution as a whole. Usually, you think big there, as you don't go too much into details of different components. Architecture ensures that different parts of solution can easily talk with one another either directly or through a mediator, it concerns security, performance, non functional deployment and system requirements. Architecture takes care of 4 and 5 scopes and sometimes 3.
Design patterns don't really grasp those problems, because they are meant to serve as a template for a part of isolated problem: to create something, to delegate work, to simplify structure… Architecture is meant to combine everything in a working system.
-----------------------------

#1....
Design pattern term is mostly used to identify some object level solutions addressing common design problems following object oriented design principles. These patterns are technology/platform agnostic, pure and domain independent. So they rely on only few assumptions. Main motivation is to design more maintainable and extensible objects by loosen up object dependencies.
Software architecture term refers to broader concept than library level object design. It is about designing and integrating databases, libraries, services, servers, configuration, communication protocols, workflows etc. Software architect should consider every non-functional requirement (reliability, scalability etc.) and choose paradigms and technologies based on them.
MVC is a compound UI design pattern which could be considered as UI architecture in the narrow sense. UI is only a one part of a software architecture problem. That’s why I would call MVC as design pattern rather than an architecture. Sometimes we call it enterprise architecture pattern too. (see Fowler, PEAA, 2003)
#2.....
It's difficult to differentiate the two terms, but I would say the architecture of an application refers to the larger structure and organization of the application, while a design pattern refers to a method of solving a specific type of problem, typically much more focused and lower level than the global structure of the system. For example, a design pattern can be a solution to the problem of an object's behaviour depending on its internal state, or when the behaviour of an object depends on the state of other objects in the system. With architectural level design, you aren't worried about details of how each piece is going to work, you're concerned with how to structure all the pieces together.
I would say an MVC is somewhere in between a design pattern and an architectural pattern. With an MVC (Laravel is the one I'm most used to), you want to separate the system models (or distinct actors in the system), from the controllers, which manipulate and process models, from the views, which are rendered based on data passed from the controller after processing and manipulating models. Typically, when a url is entered, that triggers a method on a controller to be called. That controller will create the necessary models, do some processing, and finally pass the processed data to the view, which renders the html. 

Software architect Interview Question and Answers


SOFTWARE ARCHITECTURE AND DESIGN  QUESTIONS & ANSWERS

1.     Question 1. What Are The Major Issues Associated With Managing Product Line Evolution?
Answer :
Adopting a product line paradigm creates an organizational shift. Managing product line evolution is the most difficult part of the paradigm. The product line will change as new versions of the current product come out. An organization would need to use the new versions to satisfy changing client needs. Additionally, new improvements to various components may change the way the products are built. New version of components may not be entirely backward compatible, thus additional rework will need to be done to accommodate the changes.
2.     Question 2. What Is The Basic Approach To Problem Solving In The Blackboard Framework?
Answer :
The blackboard framework is a dynamic group of independent entities that communicate and work together in order to solve some common problem. The knowledge sources adds a solution piece to the blackboard data structure when they (independently) think it’s appropriate. There is no centralized control mechanism that makes decisions as to when a knowledge source needs to contribute some piece of information. Rather the control entity states the conditions of when and each knowledge source need to contribute. The knowledge sources observe the commotion on the blackboard and contribute to progress independently.
3.     Question 3. What Are The Components Of The Blackboard Model?
Answer :
The blackboard model is usually composed of three components: knowledge sources, blackboard data structure, and control. The knowledge source component represents the chunks of information that is needed in order to solve a problem. These sources are separate from each other. The blackboard data structure can be looked at as a repository for the final solution. In this storage receptacle the final solution is slowly developed based on the sources and controls used. The control is not a module, but rather a mechanism or an abstract algorithm that specifies how a problem will be solved.
4.     Question 4. In Addition To The Architecture Itself, What Are The Assets That Can Be Considered As Members Of A Product Line?
Answer :
A collection of assets includes the following elements: 
o   Components – this asset does not directly deal with re-use of code, it encompasses and utilizes all elements of previously built successful parts (components) of the system. This includes re-use of design, documentation, structure, and etc. of components. 
o   Personnel – when the products have the same structure, then workers can shift from project to project and be able to quickly understand and adapt to changes.
o   Defect elimination – when a component is re-used in different projects, eliminating a fault in one component solves problems in multiple projects.
o   Project Planning – previous experiences help planning.
o   Performance – these issues are similar from product to product. Predictability increases.
o   Processes, methods, and tools – re-use occurs extensively, as the way components have been developed before is well known and understood.
o   Exemplar systems – the benefit of seeing systems in action and in operation shows that an organization can deliver on its promises.

5.     Question 5. What Is The Main Function Of The Hla?
Answer :
The main function of the High Level Architecture is to establish a common infrastructure, or the foundation, for a building other components of a system. The infrastructure is then used and re-used by other components of a system that rely on communication and other resources through HLA. This non-software blueprint of a system has been used by the AMG to create an environment that supports interoperability and reusability. Interface specification is used to coordinate communication efforts of various components that are built on top of the HLA.
6.     Question 6. When Is Middleware Not Appropriate?
Answer :
Middleware can get very complex and difficult to develop. The difficulties arise from the need to know the location of the servers and the amount of low-level details exposed. Certain domain specific systems with hard real-time systems may not afford to use a middleware services as that may slow down transaction speeds between an OS and applications. If a development company does not trust the middleware vendors, due to the secrecy of client’s data transmitted between databases and some applications, then that company may need to implement such middleware layer in-house.
7.     Question 7. What Kinds Of Changes Are Difficult For An Object-oriented System To Handle?
Answer :
Managing changes to an object’s identify is the most significant disadvantage of an object-oriented system. If an identify of an object changes, then all other objects that use that identify must be updated in order to reflect the change in just one object. Manageability of various objects becomes a major issue.
8.     Question 8. Can An Object (in The Architectural Sense) Have Multiple Interfaces? Is Such A Feature Desirable?
Answer :
Yes, an object can have multiple interfaces. From an architectural point of view there are advantages to having multiple interfaces. Because an object preserves the integrity of data it contains, the only way to send messages to that object is via interfaces. Thus if some object A wants to communicate with some other object B, then it has to talk through an interface. One interface does not fit the needs of all objects, thus it is useful to have multiple interfaces to promote communication between different objects that have different requirements.
9.     Question 9. How Can The Activity Of A Filter Be Triggered?
Answer :
The activity of a filter is triggered when there is information to be processed. When the pipe runs dry and no information is incoming a filter may fall asleep until more information arrives. Additionally, feedback and feedforward controls are responsible for continuing feeding information back into a filter.
10.  Question 10. What Problems Does Architecture Analysis Solve?
Answer :
Software defects that lead to security problems come in two major flavors:
o   bugs in the implementation and
o   flaws in the design.
Implementation bugs in code account for at least half of the overall software security problem. The other half involves a different kind of software defect occurring at the design level. The division of design flaws and bugs is about 50/50. Both need to be secured to ensure your software’s well-being. You can institute the best code review program on the planet, with the strongest tools known to humanity, but it’s unlikely that you will be able to find and fix flaws this way.
4 ways to identify flaws
o   Analyze fundamental design principles.
o   Assess the attack surface.
o   Enumerate various threat agents.
o   Identify weaknesses and gaps in security controls.
It is far more cost-effective to identify and remediate design flaws early in the design process than to patch flawed design implementations after deployment. Architecture risk analysis (ARA), Threat Modeling, and Security Control Design Analysis (SCDA) are useful in finding and fixing design flaws.
SCDAs are a light-weight approach to ARA. They take less time to conduct and can be carried out by a much larger talent pool than traditional ARA reviews. Most importantly, the lightweight approach is efficient enough that it can be scaled to cover an entire application portfolio.
Organizations failing to integrate architecture and design reviews in the development process are often surprised to find that their software suffers from systemic faults both at the design level and in the implementation. In many cases, the defects uncovered in penetration testing could have been identified more easily through other techniques—earlier in the life cycle. Testers who use architecture analysis results to direct their work often reap greater benefit.
11.  Question 11. What’s The Relationship Between Software Architecture And Software Design?
Answer :
Software architecture exposes the structure of a system while hiding the implementation details. Architecture also focuses on how the elements and components within a system interact with one other. Software design delves deeper into the implementation details of the system. Design concerns include the selection of data structures and algorithms, or the implementation details of individual components.
Architecture and design concerns often overlap. Rather than use hard and fast rules to distinguish between architecture and design, it makes sense to combine them. In some cases, decisions are clearly more architectural in nature. In other cases, decisions focus heavily on design and how it helps to realize that architecture.
An important detail to note is that architecture is design, but not all design is architectural. In practice, the architect is the one who draws the line between software architecture (architectural design) and detailed design (non-architectural design). There are no rules or guidelines that fit all cases—although, there have been attempts to formalize the distinction.
Current trends in software architecture assume that the design evolves over time and that a software architect cannot know everything up front to fully architect a system. The design generally evolves during the implementation stages of the system. The software architect continuously learns and tests the design against real world requirements.
12.  Question 12. What Is Software Design?
Answer :
Software design is the process of conceptualizing the software requirements into software implementation. This is the initial phase within the software development life cycle (SDLC)—shifting the concentration from the problem to the solution.
When conceptualizing the software, the design process establishes a plan that takes the user requirements as challenges and works to identify optimum solutions. The plan should determine the best possible design for implementing the intended solution.
Software design includes all activities that aid in the transformation from requirement specification to implementation.
Major artifacts of the software design process include:
Software requirements specification: This document describes the expected behavior of the system in the form of functional and non-functional requirements. These requirements should be clear, actionable, measurable, and traceable to business requirements. Requirements should also define how the software should interact with humans, hardware, and other systems.
High-level design: The high-level design breaks the system’s architectural design into a less-abstracted view of sub-systems and modules and depicts their interaction with each other. This high-level design perspective focuses on how the system, along with all its components, implements in the form of modules. It recognizes the modular structure of each sub-system and their interaction among one another.
Detailed design: Detailed design involves the implementation of what is visible as a system and its sub-systems in a high-level design. This activity is more detailed towards modules and their implementations. It defines a logical structure of each module and their interfaces to communicate with other modules.
13.  Question 13. What Is Software Architecture?
Answer :
The software architecture of a system depicts the system’s organization or structure, and provides an explanation of how it behaves. A system represents the collection of components that accomplish a specific function or set of functions. In other words, the software architecture provides a sturdy foundation on which software can be built.
A series of architecture decisions and trade-offs impact quality, performance, maintainability, and overall success of the system. Failing to consider common problems and long-term consequences can put your system at risk.
There are multiple high-level architecture patterns and principles commonly used in modern systems. These are often referred to as architectural styles. The architecture of a software system is rarely limited to a single architectural style. Instead, a combination of styles often make up the complete system.
14.  Question 14. How Do Engineering Disciplines Evolve?
Answer :
The engineering disciplines evolve from ad hoc state in two steps. Initially, talented and passionate amateurs pioneer the discipline. They achieve their goals by all means necessary – usually irrationally using available resources. Later the routine production occurs. With time the need for advancement arises and supporting science for an engineering discipline emerges. The maturing science eventuallys turn into a “professional engineering practice,” where science will become the main driving force of a discipline.
15.  Question 15. What Are Four Methods That Are Commonly Used By Architects To Build Systems?
Answer :
Normative, rational, argumentative, heuristic methodologies. The selection of the four methods depends on the circumstances of the project and a problem at hand. The first two methodologies are widely practiced in engineering institutions.
16.  Question 16. What Influences Architect’s Decisions?
Answer :
Architect’s decisions are influenced by the system stakeholders, technical environment, problem domain area, organization’s intellectual assets, architect’s education and experience, and politics.
17.  Question 17. Why Do You Need To Have Multiple Views To Accurately Describe System Architecture?
Answer :
Each view has a specific goals and a purpose; each view accomplishes different objectives. Multiple views of a system provide an abstraction – a developer does not always need to see the whole system and all of its components. Additionally, different stakeholders need different views to understand their role in the system. This promotes understanding for all stakeholders and saves time, as some stakeholders may not care at all about someone else’s view. Finally, multiple views allow for a more concrete view. It is not possible to fit all components of the system on one sheet of paper and make clear sense of it.
18.  Question 18. What Are The Principles Of Good Architectural Documentation?
Answer :
o   Statement of requirements establishes the problem boundary, puts the problem in perspective and explains why the work to be done makes sense. This is the most critical part of documentation as it gives a reader the perspective of a problem.
o   Description of context provides a list of inputs and outputs that will interact with a system at stake. Additionally, this description shows the interfaces of the external systems.
o   Use of architectural diagrams allows for improved communication and understanding of a system to be developed. The diagrams depict a developer’s imagination, and allow others to see how an original developer envisioned a system.
o   Consideration of implementation-level constraints prevents developers from fantasizing about a system that cannot be implemented. If a developer is working with a data-oriented repository style some of the implementation-level constraints may depend on hardware. Addressing these issues early build confidence among many stakeholders – to convince them that a system at stake is indeed possible.
o   Rationale for architectural design discusses different options and considerations that were entertained before a set architecture was chosen. Keeping a record of the rationale is important, as new employees or system maintainers will question the decisions later.
19.  Question 19. What Is The Essential Role Of A Software Architect?
Answer :
Making the right decisions at the right time is the chief responsibility of a software architect. Specifically the architect must evaluate various design options in light of overall system objectives and constraints. Each architectural decision has its benefits and costs, and since it is not possible to achieve all quality attributes that one may desire, an architect must make tradeoffs between available options.
20.  Question 20. What Is The Difference Between Routine And Innovative Design?
Answer :
Routine design aims at “solving familiar problems” and designing solutions by using the knowledge base from previous projects and experiences. For example, an accounting (payroll) system would most likely involve routine design; as such systems have been in production for a long time and are well understood. Routine design involves a lot of re-use and occurs much more frequently than an innovative design that requires original thinking. Innovative design is opposite of routine design, and aims at solving problems that do not have any previous knowledge base. Innovative design aims at solving original and unique problems, such as controlling an unmanned helicopter through a remote control center.
21.  Question 21. When Should You Seriously Consider Using The Process Control Paradigm To Organize A Software System (or Part Of One)?
Answer :
Process control paradigm is ideal for the systems that require continuous monitoring of certain output values. In such systems the output values need to be at a specified range in order for the system to function. This paradigm may be applied to real-time systems, where the timing is a critical element of system requirements. An autopilot system is a good candidate for process control paradigm. Altitude control element of an autopilot system is an example of a closed-loop system, as the system must be running continuously (reading information from sensors and processing acting accordingly). A set point of such system would be a specified attitude, and an input variable would be the data from the altimeter. The manipulated variables would be the engine thrust and the elevators of an airplane. The goal of the system would be to maintain the specified altitude (controlled variable) to ensure a smooth flight.
22.  Question 22. How Do You Reason About The Functionality Of Pure Pipe-and-filter Systems? For Example, If Filter F With Input Stream X Delivers The Output Stream F(x), What Does The Following Compute? Why?
Answer :
The nature of the pure pipe-and-filter systems allows an architect to construct complex data flow system from simpler components. This method allows an architect to understand, in detail, the properties of simpler components. Additionally, an architect can start from a simple system with just a few components, and then build up a more complex system. We can reason about the example in the following manner. It is given that when the input stream X enters filter F, the output stream will be F(X). The output stream F(X) sequentially becomes an input stream to filter G, and the output stream of filter G is G(F(X)). In a similar manner the input stream G(F(X)) enters filter H and the final output stream of the system is H(G(F(X))). The following computation leads to the final result by using the results of previous computation.
23.  Question 23. What Is An Open Proprietary Architectural Standard?
Answer :
An open proprietary architectural standard is promoted by Morris and Ferguson who make case for open systems where the “complex of standards and rules” would be freely published. This open standard would allow anyone to see how the system was designed and constructed. This open-ended architecture would allow the software to evolve, because any enhancements to the software would have to adhere to a defined architectural, and freely available, standard. An example of an open proprietary product is the CCITT fax standard and the NTSC television standard. An example of a closed proprietary product is Adobe’s PDF file format and Windows 2000 OS, as no one but the company can make changes to the architecture.


Baisic Useful Git Commands

  Pushing a fresh repository Create a fresh repository(Any cloud repository). Open terminal (for mac ) and command (windows) and type the be...