6.2. DAO Design Considerations

When implementing your DAO classes for your DAO interfaces, it is recommended to use a design that includes the DAO interface, an abstract (base) class, and a concrete class. The advantage to having the base class is that it can contain common methods that simplify the usage of your persistence approach (wrapping up exception handling, transaction acquisition, etc.).

DAO Implementation Diagram

Notice that the BaseDao implements the IDao marker and leaves the IAccountDao without it. Furthermore, the concrete AccountDao implements both by implementing the IAccountDao and extending the BaseDao. This allows your Account interface API to remain free of the IDao marker.