Trying to understand something that I don’t know how to describe because I don’t understand it 🙁
Let’s say I’m making a zoo application and I would like to sell different animals for the zoo. I imagine having a IAnimal interface like the following:
public interface IAnimal
{
string Talk { get; set; }
}
Now will I create a project for Cat and a project for Dog
public class Cat : IAnimal
{
...
}
let’s say i give away the zoo application and the user opens it, what’s the code look like to check what animals this user has purchase?
This is a prime case for Dependency Injection using the Inversion of Control pattern. StructureMap is an open source project that allows you to inject dependencies into your application. It allows you to say, “In this assembly, find all of the implementations of a particular interface and allow me to create an instance of any of those implementations”. This loose coupling makes for easier unit testing scenarios as well.