Showing posts with label IOC. Show all posts
Showing posts with label IOC. Show all posts

Wednesday, May 12, 2010

Publishing a open source project on CodePlex

In 2 days later, I published NMA project on CodePlex. Now you can access to my project with URL http://nma.codeplex.com. Now I'm trying to finishing this project. I finished the all layers except for UI layer. And now I 'm designing the GUI for it.
In next post, I intend to writing the series posts about NMA project. Some posts that I wrote in past as:

http://thangcq.blogspot.com/2010/04/mocking-lamda-expression-method.html
http://thangcq.blogspot.com/2010/04/converting-expression-tree.html
http://thangcq.blogspot.com/2010/04/configurating-automapper.html
http://thangcq.blogspot.com/2010/04/customizing-controller-factory-used-ioc.html
http://thangcq.blogspot.com/2010/05/unit-testing-uses-nunit-in-visual.html

Hope I will write many posts in future!

Thursday, March 25, 2010

Five Rules for IOC container

Today, I found the interesting article about 5 rules in using IOC container. And I really eager about it. In this article impressed in Service Locator is dead, and we need saying no with it. That is five rules about using IOC container:

+ Rule 1: Store in IoC container only services. Do not store any entities
+ Rule 2: Any class having more then 3 dependencies should be questioned for SRP violation
+ Rule 3: Every dependency of the class has to be presented in a transparent manner in a class constructor
+ Rule 4: Every constructor of a class being resolved should not have any implementation other then accepting a set of its own dependencies
+ Rule 5: IoC container should be explicitly used only in Bootstrapper. Any other “IoC enabled” code (including the unit tests) should be completely agnostic about the existence of IoC container

Inspite of it really old, publishing in 2009 but this article have something that I interested in. And we need make sense about Opaque dependencies and Tranparent Dependencies. What happen here if I use opaque denpendencies? It's make your class very hard for unit testing because it's seen hidden dependency class in your class. So you don't know to testing your class anywhere.In this articles of Mark Seemann, he's only showed for us about Oquaque Dependencies and he talked Service Locator is anti-pattern. But according to me, if we can use Transparent Dependencies, we can realize that Service Locator still use in the other context, and make your class don't know anything about existence Service Locator on it. In this articles, malovicn also showed for us about using internal key word for internal constructor, it's really useful for us when design the class that using Service Locator