Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Question about design pattern

 
Apratim Khandalkar
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You are creating a web application for an online product ordering system. You have decided to use connection pooling to reduce load on the databases. Since you have many databases, you want to create one pool instance of the ConnectionPool class for each database. Depending on what is requested, you may have to connect to a variable number of databases. What pattern should you use?
a) Abstract factoryb) Factory Method
c) Builder d) Prototype
e) Singleton


The correct answer is Singleton but i think it should be abstract factory?
 
Bajji Pat
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Apratim Khandalkar:
You are creating a web application for an online product ordering system. You have decided to use connection pooling to reduce load on the databases. Since you have many databases, you want to create one pool instance of the ConnectionPool class for each database. Depending on what is requested, you may have to connect to a variable number of databases. What pattern should you use?
a) Abstract factoryb) Factory Method
c) Builder d) Prototype
e) Singleton
The correct answer is Singleton but i think it should be abstract factory?


I think Singleton is the answer since each of the delegating component (say different sub-systems of the ordering system) would know the DB to connect to and it cannot be from a centralized place (i.e. We get to mention the target DB to connect to from the controller) in which case Abstract Factory would be correct answer!!
[ May 04, 2006: Message edited by: Bajji Pat ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic