Take the 2-minute tour ×

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?

share|improve this question

closed as not a real question by casperOne Jan 31 '12 at 15:51


You'll somehow need to identify which assemblies (projects) should be known by your Zoo application (whether that is scanning a directory or explicit configuration). Once you've done that you'll end up with a list of animal types found in the assemblies found. –  M.Babcock Jan 30 '12 at 1:21

2 Answers 2

up vote 0 down vote accepted

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.

share|improve this answer

Depending on the amount of pluggability required it may be worth investigating MEF, the documentation includes a sample calculator app that should help.

share|improve this answer
