Tech Point Fundamentals

Friday, March 11, 2022

Design Patterns Interview Questions - Part 02

Design Patterns Interview Questions and Answers - Part 02

design-pattern-interview-questions



In Software Industry the Design Patterns and Principles are always followed. So this is the most common topic for the interview. In this article, we will see the most frequently asked 90+ Design Patterns and Principles Interview Questions with Answers

Please visit our YouTube Channel for Interviews and other videos by below link:


Please read the C# Interview Questions and Answers article series here.



Introduction


This is the 2nd part of this Design Patterns and Principles Interview Questions and Answers article series. Each part contains eight Design Pattern Interview Questions. Please read all the Design Patterns and Principles Interview Questions list here.

I will highly recommend to please read the previous parts over here before continuing the current part:





Design Patterns Interview Questions - Part 02


Q09. What is Monolithic Architecture? What are the advantages of using it?

A monolithic architecture is the traditional unified model for software design. Monolithic means composed all in one piece. Monolithic software is designed to be self-contained.

So the components of the program are interconnected and interdependent rather than loosely coupled as is the case with modular software programs. A monolithic application is built as a single unit. 

Monolithic is an all-in-one architecture, wherein all aspects of the software operate as a single unit. In a tightly-coupled architecture, each component and its associated components must be present in order for code to be executed or compiled.



Advantage and Disadvantages of Monolithic Architecture:

  1. It is easier to test and debug the monolithic architecture. 
  2. It is easier to develop and deploy because the monolithic architecture only requires a single file or directory to set it in motion. 
  3. It is easier to take care of issues that affect the whole application i.e. "cross-cutting concerns".  Since everything is in one place and not dispersed between microservices, these are easier to manage.
  4. It is hard to scale or change the monolithic architecture. The entire application must scale all at once.
  5. It is challenging to integrate with new technology. 
  6. The code becomes complicated since everything is in one place.



Q10. What is Microservices Architecture? What is the difference between Microservices Architecture and Monolithic Architecture? 

Microservices architecture refers to an architectural style for developing applications where a large application is separated into smaller independent parts, and each part has its own role and responsibility. 

Microservices architecture is a type of application architecture where the application is developed as a collection of services. In the microservices model, components are modular, functioning independently, and coupled together as needed for optimal functionality.

A microservices architecture consists of a collection of small, autonomous services. Each service is self-contained and implements a single business capability within a bounded context. 

Services are responsible for persisting their own data or external state. This differs from the traditional model, where a separate data layer handles data persistence. Services communicate with each other by using well-defined APIs. Internal implementation details of each service are hidden from other services.



Feature and Advantage of Microservices:

  1. Microservices are small, independent, and loosely coupled. A single small team of developers can write and maintain a service. 
  2. Each service is a separate codebase, which can be managed by a small development team.
  3. Services can be deployed independently. A team can update an existing service without rebuilding and redeploying the entire application.
  4. Microservice has better fault isolation because if an individual microservice becomes unavailable, it won't disrupt the entire application, as long as any upstream microservices are designed to handle faults correctly.
  5. Microservices have better scalability because services can be scaled independently. Using an orchestrator such as Kubernetes or Service Fabric, you can pack a higher density of services onto a single host, which allows for more efficient utilization of resources.
  6. Microservice can contain a mix of different technologies. A small and focused team can build, test, and deploy it.
  7. Since microservices have data isolation, it is much easier to perform schema updates, because only a single microservice is affected. 



Q11. What is Service-Oriented Architecture (SOA)? What are the advantages of SOA?

A Service-Oriented Architecture is a design pattern that is designed to build distributed systems that deliver services to other applications through the protocol. It is only a concept and not limited to any programming language or platform.

Before SOA (the 1990s) connecting an application to services housed in another system was a complex process involving deep point-to-point integration—connectivity, routing, translation of data models, etc. This model was known as "monolithic" because the code for the whole app was built into one deployment.

Service-oriented architecture is a type of software design that makes software components reusable using service interfaces that use a common communication language over a network.  

In SOA, services use protocols that describe how they pass and parse messages using description metadata. This metadata describes both the functional characteristics of the service and quality-of-service characteristics.

SOA integrates software components that have been separately deployed and maintained and allows them to communicate and work together to form software applications across different systems.



In SOA there are different components like a service, service provider, service consumer, service locator, and service broker. 

A service provider creates web services and provides them to a service registry. The service provider is responsible for the terms of use of the service. 

A service broker or service registry is responsible for providing information about the service to a requester. A broker may be public or private. 

A service requester finds service in a service broker or service registry and then will connect with the service provider to receive the service.



Advantage of SOA:

  1. SOAs are loosely coupled self-contained, location-transparent, and support interoperability.
  2. SOA is easy to integrate as it is not very complex like monolithic applications.
  3. SOA is platform-independent as they can communicate with other applications through a common language.
  4. SOA follows layer-based architecture and provides parallel development.
  5. SOA is more reliable as services are small in size, it is easier to test and debug them.



Q12. What is the Waterfall Model of software development? 

Software projects follow a methodology of clearly defined processes or software development life cycle (SDLC) to ensure the end product is of high quality. 

An SDLC identifies phases and the structured flow from one phase to another phase. Typically, there are six to seven phases. Agile and waterfall are the two most popular models but very different, development processes.

The Waterfall Model methodology is also known as Liner Sequential Life Cycle Model. Since Waterfall Model follows a sequential order, the project development team only moves to the next phase of development or testing if the previous step is completed successfully. 

Waterfall project management is a traditional model for developing engineering systems and is originally based on manufacturing and construction industry projects.



Advantage of Waterfall Model:

  1. It is one of the easiest models to manage because of its nature, each phase has specific deliverables and a review process.
  2. It works well for smaller size projects where requirements are easily understandable.
  3. Faster delivery of the project
  4. Process and results are well documented.
  5. Easily adaptable method for shifting teams
  6. This project management methodology is beneficial to manage dependencies.




Q13. What is Agile Methodology? How it is different from the Traditional Waterfall process model?

Agile methodology is a type of incremental approach to software development based on principles that focuses more on people, results, collaboration, and flexible responses to change. 

Instead of planning for the whole project, it breaks down the development process in small increments completed in iterations or short time frames. Each iteration includes all SDLC phases such that a working product is delivered at the end. After several iterations, a new or updated product is released.

Agile methodology is a practice that helps continuous iteration of development and testing in the software development process. In this model, development and testing activities are concurrent, unlike the Waterfall model. This process allows more communication between customers, developers, managers, and testers.



Advantages of the Agile Model:

  1. It is a focused client process. So, it makes sure that the client is continuously involved during every stage.
  2. The process is completely based on incremental progress. Therefore, the client and team know exactly what is complete and what is not. This reduces risk in the development process.
  3. The agile software development method assures that quality of the development is maintained.
  4. Agile teams are extremely motivated and self-organized so it likely to provide a better result from the development projects.



Q14. What is the difference between the Agile Process Model and the Traditional Waterfall Process Model?

  1. Agile is an incremental and iterative approach while Waterfall is a linear and sequential approach.
  2. Agile separates the project into multiple sprints while Waterfall divides a project into phases.
  3. The waterfall is a Liner Sequential Life Cycle Model whereas Agile is a continuous iteration of development and testing in the software development process.
  4. Agile introduces a product mindset with a focus on customer satisfaction while Waterfall focuses on successful project delivery.
  5. Requirements are prepared every day in Agile, while requirements are prepared once at the start in Waterfall.
  6. Agile allows requirement changes at any time but Waterfall avoids scope changes once the project starts.
  7. Testing is performed concurrently with development in Agile while the testing phase comes only after the build phase in a Waterfall project.
  8. Test teams in Agile can take part in requirements change but test teams in Waterfall do not get involved in requirements change.
  9. The Agile methodology is known for its flexibility whereas Waterfall is a structured software development methodology.



Q15. What is Cohesion?  How does it play a vital role in application design?

Cohesion is the degree to which the elements inside a module belong together. A module could be a class or a package or even a microservice. Cohesion says “the code that changes together, stays together”.

Cohesion is defined as the degree to which the elements of a particular module are functionally related. cohesion is used to measure the functional strength of a module. This helps in improving the focus on a given task and thus, high cohesion is preferred.

A module with high cohesion contains elements that are tightly related to each other and united in their purpose. A module is said to have low cohesion if it contains unrelated elements. The concept of cohesion is closely related to the Single Responsibility Principle of SOLID.



Types of Cohesion: There are various types of cohesion.

Functional Cohesion: In this type of cohesion, the elements inside a module work together to achieve one common goal. 

Sequential Cohesion: In this type of cohesion, the output of a particular activity acts as an input to another. This helps in easy maintenance and provides good coupling due to a well-defined sequence.

Logical Cohesion: Logical Cohesion is a type of cohesion in which all the elements within a module perform similar operations such as error handling.



Advantage of Cohesion:

  • Modules with a single, well-defined purpose are easy to understand and much more readable. 
  • It is easier to make code changes since all the related code is within the module.
  • It is easier to test the code. Since such modules do not depend on other modules for their purpose, they are easy to unit test.
  • Overall, highly cohesive modules reflect better quality of software design.




Q16. What is Coupling?  How does it play a vital role in software design?

Coupling is the degree of interdependence between software modules. Effectively, the coupling is about how changing one thing required change in another.

Coupling is defined as the degree to which the two modules are dependent on each other. It measures the strength of relationships between modules. 

Two modules have high coupling or tight coupling if they are closely connected. Modules with low coupling among them work mostly independently of each other.



Types of Coupling:

Data Coupling: In this type of coupling, one or more than one data item is passed between the interacting modules, thus resulting in interdependency between the modules. 

Content Coupling: In this type of coupling, the interacting modules share code with each other. Basically, here one module depends on the implementation of the other module.

Control Coupling: Control Coupling is a type of coupling which occurs when one function controls the flow of another function. 

No Direct Coupling: There is no direct connection between the modules. This form of coupling is desired as these modules have no interdependency and can focus on their tasks.



Advantage of Low Coupling:

A good application should have low coupling because:

  • Tightly coupled modules are difficult to change
  • Tightly coupled modules are also difficult to test




Q17. What is the difference between Cohesion and Coupling? What is the relationship between them? 

Cohesion and Coupling are two important terminologies in software engineering. Both of them relate to the interconnection between different parts of a system. Cohesion and coupling are related to each other. Each can affect the level of the other. High cohesion correlates with loose coupling. 

A Coupling describes the relationships between modules, and Cohesion describes the relationships within them. The major difference between cohesion and coupling is that cohesion deals with the interconnection between the elements of the same module while coupling deals with the interdependence between software modules. 



A module having its elements tightly related to each other and serving a single purpose would sparingly interact and depend on other modules. Thus, will have loose coupling with other modules.

Similarly, the tight coupling could be a sign of low cohesion. Modules could be heavily dependent on each other due to the elements spread across the two modules. And thus, will have low cohesion.

So a good software application should have high cohesion and low coupling. Please read more here.



To Be Continued Part-03...


Recommended Articles






Thanks for visiting this page. Please follow and join us on LinkedInFacebookTelegramQuoraYouTubeTwitterPinterestTumblerVK, and WhatsApp for regular updates.

    

No comments:

Post a Comment

Please do not enter any HTML. JavaScript or spam link in the comment box.