| Author |
Real Time Scenario For Singleton Desgnpatter and DAO design pattern
|
Deepak Sahu
Greenhorn
Joined: Dec 08, 2009
Posts: 15
|
|
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
Joined: May 19, 2008
Posts: 77
|
|
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
|
<a href="http://stackoverflow.com/users/668970/user668970" rel="nofollow">
<img src="http://stackoverflow.com/users/flair/668970.png" >
</a>
|
 |
 |
|
|
subject: Real Time Scenario For Singleton Desgnpatter and DAO design pattern
|
|
|