Question about DAO Pattern
0 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   big_BADguy
Posted On:   Wednesday, January 4, 2006 10:39 AM

DAO pattern advocate to have a DAO class like: public class ExampleDAO implements GenericDAO { public ExampleDAO() {} public Example createExample(...) { DAOFactory.create(Example.class, ...); } public Example findExample(...) { DAOFactory.find(Example.class, ...); } public Example findExampleBySomething(...) { } } Is it bad design / anti-pattern to have implementation like: public class Example { public static create(...) { DAOFactory.create(Example.class, ...); } public static find(...) { DAOFactory.find(Example.class, ...); } public getXXX() { ... }    More>>

DAO pattern advocate to have a DAO class like:

			
public class ExampleDAO implements GenericDAO {
public ExampleDAO() {}

public Example createExample(...) {
DAOFactory.create(Example.class, ...);
}
public Example findExample(...) {
DAOFactory.find(Example.class, ...);
}
public Example findExampleBySomething(...) {
}
}


Is it bad design / anti-pattern to have implementation like:


			
public class Example {
public static create(...) {
DAOFactory.create(Example.class, ...);
}
public static find(...) {
DAOFactory.find(Example.class, ...);
}
public getXXX() { ... }
public setXXX(...) { ... }
}


I prefer the second approach because 2 reasons:


1. The code are much cleaner. And it is plain easy to understand.

2. Less class in my UML diagram, and it make more sense    <<Less
About | Sitemap | Contact