Testing controller actions and DI

Last post 01-19-2008 2:30 AM by tgmdbm. 3 replies.

Sort Posts:

  • Testing controller actions and DI

    01-18-2008, 5:10 PM
    • Member
      point Member
    • pshomov
    • Member since 01-08-2008, 2:04 AM
    • Posts 3

     Hi guys,

     

    So my first post was rather lengthy and I am guessing that's why it did not get much comments.  The summary is that in there I reported a bug in the ASP.NET MVC and second - I was wondering about the reason for choosing to register the TYPE of the factory for a controller over registering an INSTANCE of the factory. I find this choice rather unusual and I also understand that an overload of the SetControllerFactory/SetDefaultFactory which accepts instance of a factory is considered for addition. I want to understand though the reason for the current status of these methods. What kind of scenarios does providing of the type of the factory enable and is it not possible to easily/elegantly achieve the same effect using factory instances?

    Best regards,

     Petar
     

    Filed under:
  • Re: Testing controller actions and DI

    01-18-2008, 5:16 PM
    • Member
      602 point Member
    • roni_schuetz
    • Member since 07-12-2002, 5:24 AM
    • Zurich, Switzerland
    • Posts 162

    everything is abstracted - thats the motto. honestly i think it would be the best for you if you read the pattern description of the amazing "gof" - http://www.dofactory.com/Patterns/PatternAbstract.aspx

     regards

    regards, roni
    ---
    speed up your applications with distributed caching or replicated caching: http://www.sharedcache.com - its free!
  • Re: Testing controller actions and DI

    01-18-2008, 5:41 PM
    • Member
      point Member
    • pshomov
    • Member since 01-08-2008, 2:04 AM
    • Posts 3

     Hi Roni,

     I think you misunderstood my question. I do not question the need for a factory for controllers. In my original post I explained the process to get me to that question but I will try to summarize here. By providing the TYPE for the factory means that the only thing the framework can do later when it needs to instantiate a controller, is to instantiate an object of that type(the controller factory one) using a constructor with no parameters. That is the limitation that I(and seems some other people too) hit immediately on my first attempt to use the framework. You cannot inject anything into your controller factories simply because you do not set them up yourself but rather they are instantiated by the framework.

     

    Hope this clarifies my question.

     

    Regards,

     

    Petar
     

  • Re: Testing controller actions and DI

    01-19-2008, 2:30 AM
    • Contributor
      4,372 point Contributor
    • tgmdbm
    • Member since 12-17-2007, 9:08 AM
    • Posts 883
    • ASPInsiders
      TrustedFriends-MVPs

    Petar's right. Although the ControllerBuilder is using the abstract factory, it is forcing its own method of creating the ControllerFactory on us. Which we can't abstract away.

    In fact, I was kind of shocked that ControllerBuilder didn't delegate to an instance of ControllerFactory. There's too much code in ControllerBuilder if you ask me.

    And frankly, my reply to the first post was adequate. You haven't said anything new here, and if you wanted to discuss it further you should have replied in the same thread.

Page 1 of 1 (4 items)