Skip to content

Instantly share code, notes, and snippets.

@AlphaGit
Created March 20, 2016 23:44
Show Gist options
  • Save AlphaGit/3012634ea3085fe80ccc to your computer and use it in GitHub Desktop.
Save AlphaGit/3012634ea3085fe80ccc to your computer and use it in GitHub Desktop.
Decoupled Producer/Consumer classes
public class Consumer {
private IProducer _producer;
// Constructor
public Consumer(IProducer producer) {
_producer = producer;
}
public void DoConsumption() {
var value = _producer.DoProduction();
// do something with value
}
}
public interface IProducer {
object DoProduction();
}
public class Producer: IProducer {
public object DoProduction() {
return someObject;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment