200-901 Question 15
Select 2You are developing a web application for a client and need to ensure the code is modular, maintainable, and allows for easy updates to UI or business logic independently. Which design pattern(s) would provide these advantages?
- A
Model-View-Controller (MVC)
- B
Observer
- C
Singleton
- D
Factory
Show answer and explanation
Correct answers: A, B
Explanation
Both the MVC and Observer design patterns align with the requirements of the scenario. MVC ensures separation of concerns between the UI, business logic, and data layers, making the application modular and maintainable. The Observer pattern aids in keeping components in sync by notifying all observers of state changes, thereby supporting modularity and scalability. The other options (Singleton and Factory) are unrelated to the specific benefits described in the scenario.
- A. Correct.
Model-View-Controller (MVC) promotes separation of concerns by dividing the application into three interconnected components (Model, View, Controller), making it easier to maintain and extend the application independently.
- B. Correct.
The Observer pattern is useful for maintaining consistent state across multiple components by notifying dependent observers of changes, which supports modularity and scalability.
- C. Incorrect.
Singleton is a design pattern that restricts the instantiation of a class to a single object. While it can be useful in some scenarios, it does not address the modularity or maintainability requirements of the question.
- D. Incorrect.
The Factory pattern focuses on creating objects without specifying the exact class of object to be created. While useful for object creation, it does not directly address the need for modularity and separation of concerns as described in the scenario.