SOFTWARE ENGINEERING

SOFTWARE DESIGN

DESIGN PATTERNS

Question [CLICK ON ANY CHOICE TO KNOW THE RIGHT ANSWER]
Use the ____ pattern when your program is expected to process different kinds of requests in various ways, but the exact types of requests and their sequences are unknown beforehand.
A
Chain of Responsibility
B
Builder
C
Observer
D
Prototype
Explanation: 

Detailed explanation-1: -Whenever your program is expected to handle different types of requests in various ways, but the types of requests and their sequences are not known in advance, use the Chain of Responsibility pattern.

Detailed explanation-2: -Chain of Responsibility is a behavioral design pattern that lets you pass requests along a chain of handlers. Upon receiving a request, each handler decides either to process the request or to pass it to the next handler in the chain.

Detailed explanation-3: -A Chain of Responsibility Pattern says that just “avoid coupling the sender of a request to its receiver by giving multiple objects a chance to handle the request".

Detailed explanation-4: -One of the great example of Chain of Responsibility pattern is ATM Dispense machine. The user enters the amount to be dispensed and the machine dispense amount in terms of defined currency bills such as 50$, 20$, 10$ etc. If the user enters an amount that is not multiples of 10, it throws error.

There is 1 question to complete.