Java Mailing List Archive

http://www.junlu.com/

Home » Home (12/2007) » J2EE Pattern »

Re: DAO pattern

Harkness, David

2004-11-23


abhijeet rai penned

> What about DAOFactory when you have different
> databases and you write a DAOFactory which belongs to
> a an AbstractFactory pattern ?
>
> Can we do that ? Another level of Refactoring ?

Absolutely! That's a great way to abstract the specific DAO
implementation being used without the help of tools like Spring.
However, if you use static DAO methods the factory pattern won't help
you since you won't be instantiating the DAO.

Since static methods cannot be overridden (they are inherently final),
you can treat them as if the compiler *copies* the method's code to any
method that calls them. Looking at it that way, it's clear that there
will be no way to switch implementations easily at runtime without the
if-elseif-elseif-else mess from my previous post.

--
David Harkness                     Sony Pictures Digital
Sr. Software Engineer  310.482.4756   dharkness@(protected)

A "No" uttered from deepest conviction is better and greater than a
"Yes" merely uttered to please, or what is worse, to avoid trouble.

-- Mahatma Ghandi

====================================================================
Companion Site: http://www.corej2eepatterns.com
J2EE BluePrints: http://java.sun.com/blueprints/corej2eepatterns
List Archive: http://archives.java.sun.com/archives/j2eepatterns-interest.html
Unsubscribing: email "signoff J2EEPATTERNS-INTEREST" to listserv@(protected)
©2008 junlu.com - Jax Systems, LLC, U.S.A.