Created
August 4, 2010 15:26
-
-
Save thedersen/508300 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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