Bind a connectionString to every DataProvider constructor OR inject a connection interface

My Services are all accessing DataProvider classes. Each DataProvider constructor gets the connectionString as parameter injected with a DI tool.

Where is the advantage of hiding the connectionString in a IConnectionString interface and inject this interface instead of the connectionString?

Just consider for your answer: I do not use any interface to access my DataProvider classes. And these classes do not use IDbConnection.

I completely tie myself to the MS SQL Server and this is what I want :)

Answers


Injection is not only because of replacability. Its much more about testability.

If you are tied 100% to SQL Server then your tests would also be bound to Sql Server and thats not very good and makes things complicated.

If you don't use any interfaces for your dataprovider, than using interfaces fo connectionstrings would bring any benefits from my point of view.

The idea of injecting components is the depedency injection principle. s. also Martin Fowlers Post

But even if you will ever use MS SQl Server I would strongly recommend using some kind of Gateway / Repository pattern. That would give you such a better test experience and more reliable software.

As a refrence i can suggest you the cleancoders webcasts from uncle bob (Robert C Martin

http//www.cleancoders.com


Need Your Help

Bootstrap carousel, auto cycle then stop

jquery html5 css3 twitter-bootstrap

I'm using twitter bootstrap and the carousel feature. The markup is shown below.

Share partition ubuntu and Windows

windows linux ubuntu filesystems operating-system

In order to have a partition accessible in both Ubuntu and Windows I had a drive formatted as fat32(or vfat) I just found out that it does not hold single files that are more than ~4.3Gb in size. Is