I am worried that DI is the new singleton. A pattern with good intentions and fantastic helpful when used properly but slipping into the realm of the abused.
Wehn leaving Australia i was working on a project where there where dozen and dozens of unnessecary singletons. they really just ahd no reason to be there other than to slow things down.
Recently i have seen in quite bit of code using "constructor injection", no problem. But when you are passing in a object and then make this object dependent yopu are in effect providing circular references. However using interfaces this is allowed.
eg
My problem is: why?
I am seeing this specifically in the MVC pattern.
I dont need my views to know anything about my controller, so why pass the controller in as a constructor parameter. if it need to communicate with the controller raise an event, if the controller cares about this event it will subscribe to it.
I belive people are dodging using events because it seems tricky and DI is "cooler".
bollocks to that I say.
Friday, November 9, 2007
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment