Q-1). What is the purpose of the Adapter Pattern?
A-1). The Adapter Pattern allows two incompatible interfaces to work together by providing an intermediate layer that translates requests.
Q-2). How does the Facade Pattern simplify a complex system?
The Facade Pattern provides a single interface to a complex subsystem, making it easier to use and reducing dependencies.
Q-3). What is the difference between the Proxy Pattern and the Decorator Pattern?
A-3). The differences between the Proxy Pattern and the Decorator Pattern are as follows:
Proxy Pattern | Decorator Pattern |
It controls access to an object. | It dynamically adds behavior to an object |
It acts as the intermediary with the actual object | And the benefit is without modifying the structure |
Q-4). When should you use the Bridge Pattern instead of the Adapter Pattern?
A-4). Bridge Pattern is used when both abstraction and implementation should be decoupled, allowing them to evolve separately. And Adapter Pattern is used when an existing interface is incompatible and needs to be adapted.
Q-5). How does the Flyweight Pattern optimize memory usage?
A-5). The Flyweight Pattern reduces memory usage by storing shared objects instead of creating new instances for each request.
Q-6). How can the Composite Pattern be used to build a file system structure?
A-6). The Composite Pattern allows treating individual files and folders uniformly in a hierarchical tree structure.