SOFTWARE DESIGN
DESIGN PATTERNS
Question
[CLICK ON ANY CHOICE TO KNOW THE RIGHT ANSWER]
|
Define a family of algorithms, encapsulate each one, and make them interchangeable. Strategy lets the algorithm vary independently from clients that use it.
|
Strategy
|
|
Mediator
|
|
Observer
|
|
Adapter
|
Explanation:
Detailed explanation-1: -That is, you want to encapsulate several algorithms that share a common interface to make them interchangeable. Strategy-defines a family of algorithms, encapsulate each one, and make them interchangeable. Strategy lets the algorithm vary independently from clients that use it. Examples: Swing layout managers.
Detailed explanation-2: -The strategy design pattern is a Gang-of-Four (GoF) design pattern. It is a behavioral pattern used to define a family of algorithms and encapsulate each of them inside a class.
Detailed explanation-3: -“Encapsulate what varies” This principle suggests, Identify the aspects of your applications that vary and separate them from what stays the same.
There is 1 question to complete.