11

I've always used the repository pattern in my applications. But I have seen that many people use facades instead of the repository for naming convention, but the operation is the same, I Think. Why is there this difference? There are a real difference between them or not?

13

A facade is more general than a repository.

A facade can apply to anything that is not persistence based, whereas a repository is supposed to encapsulate access to an underlying source and make it look like an in memory data source.

Facades are for creating a simple interface for some other, complicated interface.

| improve this answer | |
  • So the repository is designed for communicate with data layer and facades is more generic than this. for example a facades can perform other operation but the structure in designed like a repository, right? – Mirko Mar 14 '14 at 11:52
  • 1
    @MirkoPastorelli - it can. An example of a facade would be to give a single entry point for code that actually has to deal with several subsystems. – Oded Mar 14 '14 at 11:58
  • 4
    @MirkoPastorelli: a repository is not designed for communicating with the data layer, it is designed for wrapping the communication with a data layer and "abstracting this away" from the user of the repo. (so one can, for example, provide a mock repository for testing purposes which provides only hardcoded test data and has no other dependencies). From this point of view, a repo is indeed nothing but a specific form of facade. – Doc Brown Mar 14 '14 at 12:53

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.