class UserLifecyleService { private IUserRepository userRepository; public void createUser(User user) { //do some stuff, logging, authentication,... userRepository.create(user); //do some stuff, send out an event or whatever } }So the repository it's an interface. What if later the need arise to make it an abstract class instead? Or a concrete one? Or the other way around, it was concrete then we realised that we are supposed to depend on abstractions? What's happening here is that we've exposed some implementation detail to the client of the repository, creating an unwanted coupling. If we change the type of our component, then we need to do code change in the client (here the UserLifecycleService), too.
But since it seems a default convention in C# circles (and I've come across some cases in Java projects), I'd be interested in any counter-arguments.
No comments :
Post a Comment