Monday, January 5, 2015

DI - When to 'new'

Misko advises to keep "newables" separate from "injectables" - so newing things up are okay if they are value objects. http://misko.hevery.com/2008/09/30/to-new-or-not-to-new/

I go to that article via a comment in http://misko.hevery.com/2008/07/08/how-to-think-about-the-new-operator/  where he's emphatic about doing the DI. The "newable" exception is very important to consider. Specifically, a newable is an object a DI container would have NO WAY of know how to instantiate -- like a User() or PhoneNumber.

Continued...

No comments:

Post a Comment