Is this basically what an IOC like NInject does?
Posted
by mrblah
on Stack Overflow
See other posts from Stack Overflow
or by mrblah
Published on 2009-12-18T20:40:22Z
Indexed on
2010/05/18
5:30 UTC
Read the original article
Hit count: 155
Normally I would do this:
public class DBFactory
{
public UserDAO GetUserDao()
{
return new UserDao();
}
}
Where UserDao being the concrete implementation of IUserDao.
So now my code will be littered with:
DBFactory factory = new DBFactory();
IUserDao userDao = factory.GetUserDao();
User user = userDao.GetById(1);
Now if I wanted to swap implementaitons, I would have to go to my DBFactory and change my code to call a different implementation.
Now if I used NINject, I would bind the specific implementation on application startup, or via a config file. (or bind based on specific parameters etc. etc.).
Is that all there is too it? Or is there more?
(reason I am asking if I want to know how it will help me here: http://stackoverflow.com/questions/1930328/help-designing-a-order-manager-class)
© Stack Overflow or respective owner