Pascal
Pascal

Reputation: 12885

Why should I create interfaces for my concrete DataProvider classes

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?

Upvotes: 1

Views: 180

Answers (2)

rsbarro
rsbarro

Reputation: 27349

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.

Upvotes: 1

Oded
Oded

Reputation: 499142

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.

Upvotes: 3

Related Questions