Hi, Let me try to complicate it a bit more! ;)
Have you thought about just not coding at all (the DAO implementation, that is)? Take a look at sql2java. With that, you'd have a nice DAO implementation and be able to implement just about anything you want over it. HTH, Freddy. -----Mensaje original----- De: Marco Mistroni [mailto:[EMAIL PROTECTED] Enviado el: viernes, 08 de octubre de 2004 16:21 Para: 'Struts Users Mailing List'; 'atta-ur rehman' Asunto: RE: [OT] Request for comments on DAO pattern implementation Hello, My 2 cents.. go for the interface... it will make your life Easier for the future when you want to change implementation.... Regards marco -----Original Message----- From: atta-ur rehman [mailto:[EMAIL PROTECTED] Sent: 08 October 2004 15:13 To: Struts Users Mailing List Subject: [OT] Request for comments on DAO pattern implementation 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] --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]