Monday, May 17, 2010

Design Patterns


  1. What is  the difference between an Adapter and a Facade pattern. Why do you need both of them ?
    1. Adapter is for altering an interface. Facade is to provide a simplified interface for a complex subsystem
    2. Adapter hides the altered interface from the client. Facade still exposes the subsystem interface for advanced clients.
  2. How does decorator differ from Subclassing + overriding ?
  3. What is double checking strategy in Singleton pattern ?
    1. Declare the single instance to be volatile.
    2. Synchronize block for creating instance.
    3. Check for instance null just before entering and just after entering Synchronized block before creating var.
  4. How do we circumvent the problem of a class being Singleton across classLoaders also ?

No comments: