开发者

Is the idea to hookup all business logic classes in my WinForms app via IOC? Or if not is there a guidance re which classes to use IOC on?

Getting going now with NInject... :)

For a WinForms application, and in parti开发者_运维问答cular the business logic classes used within it, is there a rule of thumb in terms of which Classes once should hook up using IOC? For example if you have a Domain Model which is modelled by C# classes is the concept that all classes should be wired together using IOC?


IOC/DI allows you to design loosely coupled systems and manage your dependencies smartly and flexibly. This means that you can use these concepts anywhere including the presentation layer e.g. PRISM. That being said, you don't have to apply them to each and every class. For example, some classes provide basic building block type functionality such as string class in .NET that it is ok to take a dependency on the concrete implementation. Otherwise, you will end with an overly complex looking code that may go against keep it simple principle. Ask yourself if you want to test your classes and how hard it is to write a unit test. If the code and the dependencies are getting in the way of easily and quickly producing unit tests, then you might want to invert those dependencies to be in charge of controlling them.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜