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?

asked Nov 12, 2013 at 18:29
4
  • 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? Commented Nov 12, 2013 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) Commented Nov 12, 2013 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. Commented Nov 12, 2013 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! Commented Nov 12, 2013 at 19:16

1 Answer 1

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.

answered Nov 12, 2013 at 20:12
2
  • Sure, it makes sense what you just said, I will keep that on mind, thanks! Commented Nov 12, 2013 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. Commented Nov 13, 2013 at 0:28

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.