Daniel Hoelbling-Inzko talks about programming
This is directly from the standard MVC template upon starting a new project:
// This constructor is used by the MVC framework to instantiate the controller using // the default forms authentication and membership providers.public AccountController() : this(null, null) { }
// This constructor is not used by the MVC framework but is instead provided for ease // of unit testing this type. See the comments at the end of this file for more // information. public AccountController(IFormsAuthentication formsAuth, IMembershipService service) { FormsAuth = formsAuth ?? new FormsAuthenticationService(); MembershipService = service ?? new AccountMembershipService(); }
I didn’t realize this is in the default template of ANY MVC install when Ayende pointed this out in his NerdDinner review yesterday. Wow, speaking of bad defaults..
If you don’t want to burden yourself with “real” IoC, at least do it right:
// This constructor is used by the MVC framework to instantiate the controller using // the default forms authentication and membership providers.public AccountController() : this(new FormsAuthenticationService(), new AccountMembershipService()) { }
// This constructor is not used by the MVC framework but is instead provided for ease // of unit testing this type. See the comments at the end of this file for more // information. public AccountController(IFormsAuthentication formsAuth, IMembershipService service) { FormsAuth = formsAuth; MembershipService = service; }