Question 14
A movie-ticket booking application currently supports payments through Credit Card, UPI, and Net Banking. The booking module creates payment objects directly as shown below.
The company plans to introduce Apple Pay, Google Pay, and additional payment methods in future releases. During code reviews, the architects observe that every new payment method requires changes to the booking module, increasing maintenance effort and the possibility of introducing defects.
Which design pattern would best improve extensibility by separating object creation from the booking module?
Builder
Observer
Factory
Facade