15

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?

1 Answer 1

16

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.

3
  • 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? Commented Mar 14, 2014 at 11:52
  • 2
    @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. Commented Mar 14, 2014 at 11:58
  • 5
    @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. Commented Mar 14, 2014 at 12:53

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.