I'm writing the service layer for my DAO and I've made it extend the DAO interface. It looks a bit like this:

public interface FooDAO {
    Foo get(long id);
    boolean update(Foo foo);

These two methods will do for now. Now, writing the Service layer over that:

public interface FooService extends FooDAO, AutoCloseable {
    // no extra methods currently

I'm thinking that the DAO provides the basic CRUD, so I might as well extend that for my service.

Since both the FooDAO and FooService interface are public, is there a reason not to expose the DAO through the Service?

1 Answer 1


The seems really weird to me.

A DAO is for moving individual records around. A service is supposed to do domain-appropriate things, such as "verify that this customer has no outstanding loans" or "ignite all the stages in the rocket in the correct order". In virtually any realistic system, these two types of actions are so different in conception that it makes little sense to imagine your service as being merely a DAO, which is what inheritance would convey.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.