Quantcast
Channel: I think I missed something on the "Programming to an interface" concept - Stack Overflow
Browsing all 7 articles
Browse latest View live

Answer by bricklayer137 for I think I missed something on the "Programming to...

Another way of thinking about the interplay between interfaces and classes is to flip them upside down. That means to start with classes first. Let's say you have several classes that expose a method...

View Article


Answer by xandy for I think I missed something on the "Programming to an...

One of the main benefit to program to ISomeInterface instead of FooClass, is that you might probably change your implementation of FooClass. For example, consider a database driven blog...

View Article


Answer by Ahmad for I think I missed something on the "Programming to an...

By using the interface definition instead of the concrete implementation, your code is now more loosely coupled. This technique is used in dependency injection. In addition, this comes in handy when...

View Article

Answer by Philipp for I think I missed something on the "Programming to an...

Do you have a C/C++ background? Then you should be aware that private ISomeInterface _someInterface;would be written asprivate: ISomeInterface& _someInterface;In C++ (assuming you have an abstract...

View Article

Answer by Dan Bryant for I think I missed something on the "Programming to an...

Suppose FooClass wrote something to a database. You'd like to test BarClass without having to actually set up a database. If you created a different TestFoo that implemented the same interface, you...

View Article


Answer by Darin Dimitrov for I think I missed something on the "Programming...

The idea is that BarClass should not be tightly coupled to a specific implementation of ISomeInterface.If you use this:public BarClass(FooClass fooClass)it means that the BarClass can work only with...

View Article

I think I missed something on the "Programming to an interface" concept

So I am still very new to C# and using interfaces, and when I thought I understood them I realized I don't completely. The confusion I have found that I am seeking some clarification here for is, when...

View Article
Browsing all 7 articles
Browse latest View live


Latest Images