B.S.W.E. Bachelor of Software Engineering Software Architecture & Design Patterns 2 — Questions and Answers
Question 1: What is the main purpose of the Repository pattern?
- To store UI components
- To abstract data access logic from business logic (Correct answer)
- To manage network requests
- To handle user authentication
Correct answer: To abstract data access logic from business logic
The Repository pattern abstracts the data layer, providing a clean API for data access to the business logic without exposing persistence details.
Question 2: Which architectural style uses stateless communication over HTTP?
- SOAP
- GraphQL
- REST (Correct answer)
- gRPC
Correct answer: REST
REST (Representational State Transfer) uses stateless HTTP communication with standard methods like GET, POST, PUT, and DELETE.
Question 3: What is 'cohesion' in software design?
- How much modules depend on each other
- How well elements within a module belong together (Correct answer)
- The number of classes in a module
- The size of a software component
Correct answer: How well elements within a module belong together
Cohesion measures how strongly related and focused the responsibilities of a single module are — high cohesion is preferred.
Question 4: Which SOLID principle states a class should have only one reason to change?
- Open/Closed Principle
- Liskov Substitution
- Single Responsibility Principle (Correct answer)
- Interface Segregation
Correct answer: Single Responsibility Principle
The Single Responsibility Principle states that a class should have only one responsibility and thus only one reason to change.
Question 5: What is the Observer pattern used for?
- Creating complex objects step by step
- Notifying multiple objects about state changes (Correct answer)
- Providing a simplified interface to complex subsystems
- Controlling access to an object
Correct answer: Notifying multiple objects about state changes
The Observer pattern defines a one-to-many dependency where multiple observers are automatically notified when the subject's state changes.
Question 6: Which architectural pattern is best suited for event-driven applications?
- Layered Architecture
- Pipe and Filter
- Event-Driven Architecture (Correct answer)
- Client-Server
Correct answer: Event-Driven Architecture
Event-Driven Architecture (EDA) is designed around the production, detection, and consumption of events for loosely coupled systems.
What is the main purpose of the Repository pattern?