Chapter 6. Implementing the DAO Interface (Creating Your Data Access Objects)

6.1. Interface

The IDao interface is simple and flexible because it does not declare any methods. It is intended to act as a marker interface only (as per the Marker Interface pattern –Grand98). In other words, by extending the IDao interface, all that is really achieved for the class that implements your DAO interface is the ability to be instantiated and managed by the DaoManager. There are no limitations to the methods that you use in your DAO interfaces. It is recommended for consistency that DAO implementations only throw exceptions of type DataAccessException which is an ApplicationException. This helps to hide the implementation details of your persistence solution.

An example of a DAO interface is:

[C#]
public interface IAccountDao : IDao {
    Account GetAccountById(int accountID);
    void Create(Account account);
    // DAO Framework code may throw DataAccessException
    void Update(Account account); 
    void Delete(Account account);
}