tags:

views:

325

answers:

4
+1  Q: 

J2EE - DAO DVO

I have seen two ways of implementing DAO-DVO design.

1) DVO are objects and DAOs are instantiated using factories i.e DAOs are also objects 2) DVOs are again objects but in this case, DAOs are classes which contain only static methods which accept DVOs to perform tasks.

I was wondering which way is better and more scalable

thanx in advance

A: 

I would strongly recommend not using that many layers unless they are really layered physically. eg if you have something like a rich client where you need to send detached objects to update the GUI, otherwise, its a world of pain.

Michael Neale
+2  A: 

Try the Spring Framework. DAOs are initialized via Dependency Injection and are just plain 'ole Java objects.

Then, the methods on the DAO should just use Domain Objects that are used at all layers of the Application.

bpapa
A: 

How to download DAO Factory to create Database Connectivity?

+1  A: 

With regards to testability, I'd advise against the second approach. Static methods prevent you from adjusting the class's behaviour by overriding collaborators with mocks and such. As Miško Hevery puts it: "Static Methods are Death to Testability".

Ole