Avishek Rocks
Avishek Rocks

Reputation: 25

Related to java design patterns - technical aptitude

  1. Connection pool is a example of which design pattern. ? FLY Weight -I think

  2. Java io library is a example of which design pattern. ? – Decorator - I think

  3. Company X is using a library bought from Company Y. But Y has now closed out. So company X bought similar library from Company Z and found that many of the classes are having differnet interfaces compared to the library from Y. What design pattern should be applied by company X to handle this situation? Adapter - i think

  4. In company XYZ, transfer between data center and users have become slow due to less bandwidth. Which design pattern should the programmer apply to sent data efficiently over the low bandwidth network?

    • Front controller & Business Delegate
    • Service locator and data access objects
    • Session Facade and Value objects - i think
    • Service to worker and Service locator.
  5. One diagram given for a design pattern where AbstractInterface is a interface which contains method A() class1 and class2 extends from Abstract interface and class2 overrides methodA(). It is mentioned that call from client comes to AbstractInterface and the interface delegates the call to respective child classes. Which design pattern is this?

Upvotes: 0

Views: 118

Answers (1)

Davide Lorenzo MARINO
Davide Lorenzo MARINO

Reputation: 26946

  1. A connection pool use the Object Pool Pattern. It differs from the flyweight because objects can be modified. Flyweight use immutable instances.
  2. Often the decorator pattern is used on the IO libraries, but not only it.
  3. Yes adapter is the right answer.
  4. If the problem is related to the format of data that needs too much bandwidth, changing it to a different format can be done using an Adapter. The object sent from client to server are value objects. Also using a cache can be useful to send data only if needed. To perform a cache that updates automatically when the data are changed on the back end you can use an Observer
  5. If I understood well the delegation pattern.

Upvotes: 1

Related Questions