问题描述:

I use much Microsoft SQL Server propriate stuff.

I do not need multiple concrete classes implementing the same interface.

So why should my DataProvider classes need an interface?

网友答案:

You should create interfaces in order to make testing code that depends on your data easier.

Having interfaces and coding to these interfaces means you can inject mocks and stubs in your tests.

网友答案:

There are probably many ways to answer this, but one advantage of using an interface (especially with a pattern like the Repository pattern) on your DataProvider is so you can mock that interface, allowing you to unit test the code that makes use of the DataProvider more easily.

相关阅读:
Top