Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Real Time Scenario For Singleton Desgnpatter and DAO design pattern

 
Deepak Sahu
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi ,

Can someone please give me example of a real time scenario where Singleton Desgnpatter and DAO design pattern is used
 
damodar kumar
Ranch Hand
Posts: 77
Android Chrome MyEclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Deepak,

First i will go for Singleton

there is a funtionallity where you are getting Meta Data on to the form, so if you hit database for every time it is overhead to server. Instead get the data for first time and keep it in cache and use it for everytime untill the Meta data is not changed, if data is changed clear it and again get it from database.

Now DAO pattern

you have a application connecting to different databases like oracle,DB2and MSSQL etc
for the above you have get connections and do some stuff for persisting the data. So for all 4 database you will have to get the 4 connection object , it means there will be 4 classes for getting connection mechanism.
Instead doing such redendunt code, have a factory class , which will give you connection object depending upon database you using .

Damodar
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic