1

Well, the thing is that I am just about to create a Desktop App (with .NET windows forms)

And now I just wonder if it would be really a wise choise to use any IoC (StructureMap,Ninject,Spring .Net), I have used them before for Asp.Net web applications but what makes me doubt now is the fact that working with windows forms my business entities will persist when I navigate through tabs and unlike than web forms or mvc apps where it would be necesary to inject my business entity for every new request that is performed, I mean this because of the Asp.Net page life cycle where is performed the initialization and controls instantiation.

Maybe I am misunderstanding the point of using an IoC, so please tell me what do you think would be a better choise?

  • We're going to need more info. For some desktop apps it makes sense, for some it doesn't. What problems are you trying to solve? – Telastyn Nov 12 '13 at 18:31
  • Well basically I want to create an app n-tier and I also would like to loose coplig beteen layers but I am not very sure if this is a good approach for windows forms (actually I have never created one enterprise desktop app) – luis_laurent Nov 12 '13 at 18:43
  • 2
    How big is this app going to be? Is it a simple utility, or an accounting system for a large corporation? Scale matters; unless the program will be pretty large, an IoC container is probably overkill. – Robert Harvey Nov 12 '13 at 18:49
  • it is kind of a long development project, it combines maintenance tracking, inventory, work orders, and management reporting. I am currently working on a proposal for architecture, that is why I asked! – luis_laurent Nov 12 '13 at 19:16
1

If I am going to work on a desktop application or tool of a even a moderate size (but with potential to grow in functionality), I have started using a dependency injection framework. People may argue that this is overkill, but I am so used to it at this point it doesn't slow me down. You could still perform injection manually if you wanted, though. My personal favorite framework, Autofac, mostly stays out of the way, and I find that it actually makes my code simpler. I prefer keeping control of object creation and lifetimes in the container. Of course, I also write tests so that is a factor.

I would say that from your description and comments, the application will be complex enough that I personally feel it justifies using DI.

  • Sure, it makes sense what you just said, I will keep that on mind, thanks! – luis_laurent Nov 12 '13 at 21:48
  • 1
    As you yourself said, the main differences are where the composition root is and what the lifestyle of your objects is. – Facio Ratio Nov 13 '13 at 0:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.