Question

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?

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
scroll top