Skip to content

Instantly share code, notes, and snippets.

@thedersen
Created August 4, 2010 15:26
Show Gist options
  • Save thedersen/508300 to your computer and use it in GitHub Desktop.
Save thedersen/508300 to your computer and use it in GitHub Desktop.
public class BlogService
{
private Repository _repository;
public BlogService()
{
_repository = new Repository();
}
public void ProcessComment(Comment comment)
{
_repository.Save(comment);
// Send notification to author and do other stuff here
}
}
public interface IRepository
{
void Save(Comment comment);
}
public class BlogService
{
private IRepository _repository;
public BlogService(IRepository repository)
{
_repository = repository;
}
public void ProcessComment(Comment comment)
{
_repository().Save(comment);
// Send notification to author and do other stuff here
}
}
public class Repository : IRepository
{
public void Save(Comment comment)
{
// Save the comment
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment