I try to use as many interfaces as possible for a good unit test and a better understanding of the program architecture.
Despite the fact that I try to follow the SOLID rule - my classes need to pass a lot of dependencies in the constructor, which turns into hell.
The search led me to IoC containers, but in fact I didn’t understand much when to use them. Passing a NInject kernel in the constructor looks like a silly idea, and creating only the main class using the NInject does not eliminate the problem with a bunch of parameters in the constructor.
I can’t reduce the number of dependencies in constructor. I don’t understand how to properly use NInject to reduce constructor parameters. How do I solve this problem?
(not the worst example)
public SomeConstructor(ISettings settings, INotification notification, IServer server, IPriceCache priceCache)
{
Settings = settings;
Notification = notificartion;
Server = server;
PriceCache = priceCache;
}
(this solution looks like a terrible idea)
public SomeConstructor(IKernel ninjectKernel)
{
Settings = ninjectKernel.Get<ISettings>();
Notification = ninjectKernel.Get<INotification>();
Server = ninjectKernel.Get<IServer>();
PriceCache = ninjectKernel.Get<IPriceCache>();
}