To preface, I would like to get some opinions from some of the regular contributors to this forum regarding this topic and potential workarounds you may be using to address the issue.
Let me also state that we are die-hard CSLA developers in my shop. The advantages of the framework are tremendous and cannot be ignored.
Earlier I posted regarding what appears to be an incompatibility between mobile objects (objects that inherit from Business*Base) and dependency injection techniques as outlined in inversion of control methodologies.
We have determined that mobile objects can easily take advantage of a service locator, both for resolving the mobile objects themselves or dependencies inside of the mobile objects. However, the service locator technique itself has several limitations: http://ubik.com.au/article/named/service_locator_vs_dependency_injection
Now for the meat and potatoes:
The reasons CSLA-derived mobile/business objects cannot take advantage of dependency injection are twofold:
Thus, when a mobile object has a dependency, the only way to get an instance of a service interface without direct instantiation is to call a global/static service locator.
Or am I completely wrong? Have any of you guys been able to implement dependency injection into your CSLA-derived business objects?
Thanks!
Bob,
I believe we’ve already started this discussion in another posting here …
On the topic:
I felt the same a month ago, and then I discovered StructureMap.
I did a lot of prototyping and was really pleased with the results.
Csla + StructureMap can work, and StructureMap is not that hard to master either…
I’d encourage you to try StructureMap (I’m using the latest 2.5 version from svn)
You just have to be clear what is it exactly you want to do...
- Some dependencies are good!
- Some you have to break for the sake of Unit Tests, and
- Some you have to break to be able to introduce totally new behavior at runtime for example…
I really don’t have the time to post a complete CSLA example now, and I guess I’m not 100% what you want to do, but if you ask a specific question I’ll spend some time putting something together soon.
BTW:
Rhino + StructureMap really changes how you write Unit Tests, and they can really be Unit, because you can inject mocks of just about anything…
This is the book that really helped me understand this:
http://monkeys.codebetter.com/blogs/karlseguin/archive/2008/01/02/foundations-of-programming-pdf.aspx
Copyright (c) Marimer LLC