Dear all,

I've contemplated two ways of implementing DAO pattern; and I'm unable
to decide which is better :) Any comments on pros and cons of these
two approaches will be greatly appericiated.

Implementation 1: Have IDAO interface and let all the DAO objects
implement this interface; with probably an abstract class in between.
Every method need to cast Object down to its relevant DTO and throw
exception if the DTO is not of expected type.

public interface IDAO {

  Object findByPrimaryKey(final Object key);
  Collection findByCriteria(final String whereClause);
  Object insert(final Object o);
  void delete(final Object o);
  void update(final Object o);
  Collection getAll();
}

public class FooDAO implements IDAO {
......
}

Or  approach 2: every DAO is a class of its own with all the methods
only accepting the expecting DTOs!

public class FooDAO {

Foo findByPrimarykey(Object pk);
insertFoo(Foo);
deleteFoo(Foo);
updateFoo(Foo)
Collection getAll();
}

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to