Hey everyone
I'm just getting started with Dependency Injection (DI) using Ninject and am working through my controllers looking to decouple them from my models a bit more.
At the moment, inside of my controllers I am creating an instance of some given model e.g:
var activitiesModel = new ActivitiesModel();
For each of my models that I've been instantiating in this way, should I extract an interface for these and then use DI to tie these things together?
An example of where I'm currently doing this is inside my ActivitiesController:
IActivitiesModel _activitiesModel;
public ActivitiesController(IActivitiesModel activitiesModel)
{
_activitiesModel = activitiesModel;
}
and this is tied together in my global.asax:
Bind<IActivitiesModel>().To<ActivitiesModel>();
Is this the correct way to go about doing this? Should I be creating a new interface for each of my models that is instantiated inside of a controller?
Cheers for any help and nudges in the right direction :-)