Look at my Controller (I'm using Dependency Injection to manager dependencies):
public RoleController(IRoleRepository roleRepository, ISiteRepository siteRepository, IUserRepository userRepository, IDbContext dbContext)
{
_roleRepository = roleRepository;
_siteRepository = siteRepository;
_userRepository = userRepository;
_dbContext = dbContext;
}
Having a class with many dependencies is a code smell? Right?
But, In my example I need to associate Users
and Sites
in a Role
, then I need to these dependencies to doing this association.
Some people on a mailing list I was told that having too many dependencies is a sign that something is probably wrong. But I see no other way. I separated my responsibilities, there is something in that situation I do not know how to treat? Is something wrong?
Update:
I need Repositories and DbContext because DbContext is my UnitOfWork, repositories don't save.
This example is a simple CRUD with some other functionalities like Associations in the View with a GRID.
Update 2:
I'm using a architecture where my UI Layer is the MVC.