<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	>
<channel>
	<title>Comments on: How to implement unit-testable abstraction and reusable domain models with IoC + ORM?</title>
	<atom:link href="http://rabdullin.com/how-to-implement-unit-testable-abstraction-and-reusable-domain-models-with-ioc-orm/feed/" rel="self" type="application/rss+xml" />
	<link>http://rabdullin.com/how-to-implement-unit-testable-abstraction-and-reusable-domain-models-with-ioc-orm/</link>
	<description>Moving towards the efficient development of smart software solutions in C# .NET</description>
	<pubDate>Mon, 08 Sep 2008 07:02:32 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.6.1</generator>
		<item>
		<title>By: Rinat Abdullin</title>
		<link>http://rabdullin.com/how-to-implement-unit-testable-abstraction-and-reusable-domain-models-with-ioc-orm/#comment-435</link>
		<dc:creator>Rinat Abdullin</dc:creator>
		<pubDate>Tue, 11 Mar 2008 12:25:23 +0000</pubDate>
		<guid isPermaLink="false">http://rabdullin.com/how-to-implement-unit-testable-abstraction-and-reusable-domain-models-with-ioc-orm/#comment-435</guid>
		<description>Jeremy,

thank you for your comprehensive comments.

Yes, moving the Resolve calls back to the super-type (along with making it protected) seems logical. Free DI-related methods with unbound service location could be really dangerous in big development teams.

And if somebody ever needs to deliver a domain object library, that is easy to extend, they can just make the Resolve public.

About the performance. Personally I'm not sure yet if using some complex logic for field initializers is worth it in the long run. That will be some repetitive code out there.

If it were possible to create some dictionary-type quick adapter on this  Resolver interface (to cache singleton and container-scoped instances) then the performance could be appropriate for the majority of UI-related usage scenarios. However, I personally haven't even profiled autofac itself.

Surviving across container scopes seems a little bit tricky for me now. In series usage scenarios (and in my projects) session always has the life cycle of the container it is in. And so are the BOs that were created with it. There could be child containers below (using the same session or UoW override, and/or BO instances from the upper container). But when this container dies, then logically everything else within it should be already on its way to the GC.

Jeremy, please, keep me updated of your findings, if you do not mind!
BTW, do you have weblog?

Best regards,
Rinat</description>
		<content:encoded><![CDATA[<p>Jeremy,</p>
<p>thank you for your comprehensive comments.</p>
<p>Yes, moving the Resolve calls back to the super-type (along with making it protected) seems logical. Free DI-related methods with unbound service location could be really dangerous in big development teams.</p>
<p>And if somebody ever needs to deliver a domain object library, that is easy to extend, they can just make the Resolve public.</p>
<p>About the performance. Personally I&#8217;m not sure yet if using some complex logic for field initializers is worth it in the long run. That will be some repetitive code out there.</p>
<p>If it were possible to create some dictionary-type quick adapter on this  Resolver interface (to cache singleton and container-scoped instances) then the performance could be appropriate for the majority of UI-related usage scenarios. However, I personally haven&#8217;t even profiled autofac itself.</p>
<p>Surviving across container scopes seems a little bit tricky for me now. In series usage scenarios (and in my projects) session always has the life cycle of the container it is in. And so are the BOs that were created with it. There could be child containers below (using the same session or UoW override, and/or BO instances from the upper container). But when this container dies, then logically everything else within it should be already on its way to the GC.</p>
<p>Jeremy, please, keep me updated of your findings, if you do not mind!<br />
BTW, do you have weblog?</p>
<p>Best regards,<br />
Rinat</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jeremy Gray</title>
		<link>http://rabdullin.com/how-to-implement-unit-testable-abstraction-and-reusable-domain-models-with-ioc-orm/#comment-430</link>
		<dc:creator>Jeremy Gray</dc:creator>
		<pubDate>Mon, 10 Mar 2008 21:33:28 +0000</pubDate>
		<guid isPermaLink="false">http://rabdullin.com/how-to-implement-unit-testable-abstraction-and-reusable-domain-models-with-ioc-orm/#comment-430</guid>
		<description>PPS - Just pretend that the Resolve calls have a type specifier on them, as it got eaten each time by the comment engine.</description>
		<content:encoded><![CDATA[<p>PPS - Just pretend that the Resolve calls have a type specifier on them, as it got eaten each time by the comment engine.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jeremy Gray</title>
		<link>http://rabdullin.com/how-to-implement-unit-testable-abstraction-and-reusable-domain-models-with-ioc-orm/#comment-429</link>
		<dc:creator>Jeremy Gray</dc:creator>
		<pubDate>Mon, 10 Mar 2008 21:32:22 +0000</pubDate>
		<guid isPermaLink="false">http://rabdullin.com/how-to-implement-unit-testable-abstraction-and-reusable-domain-models-with-ioc-orm/#comment-429</guid>
		<description>PS - This will probably be done as simply as by declaring a nice little "protected T Resolve()" method in my domain layer supertype and invoking it in my field initializers, as they'll each only be invoked upon first usage of each field. If any domain objects need to survive across container scopes, they can avoid using the fields and (at the cost of a bit more typing) do per-usage Resolve() calls any time they need access to a service.</description>
		<content:encoded><![CDATA[<p>PS - This will probably be done as simply as by declaring a nice little &#8220;protected T Resolve()&#8221; method in my domain layer supertype and invoking it in my field initializers, as they&#8217;ll each only be invoked upon first usage of each field. If any domain objects need to survive across container scopes, they can avoid using the fields and (at the cost of a bit more typing) do per-usage Resolve() calls any time they need access to a service.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jeremy Gray</title>
		<link>http://rabdullin.com/how-to-implement-unit-testable-abstraction-and-reusable-domain-models-with-ioc-orm/#comment-428</link>
		<dc:creator>Jeremy Gray</dc:creator>
		<pubDate>Mon, 10 Mar 2008 21:27:16 +0000</pubDate>
		<guid isPermaLink="false">http://rabdullin.com/how-to-implement-unit-testable-abstraction-and-reusable-domain-models-with-ioc-orm/#comment-428</guid>
		<description>Just to summarize your post modulo XPO specifics, here is what I'm gathering: Relative to the issues from earlier in the series, you've chosen to use a service locator (exposed via a layer supertype) for IoC within your domain, and continue to use use DI for IoC within your services.

This is a pretty common approach (historically the most common), getting us most of the way there, with the only main set of trade-offs being that your domain objects will have to make Resolve calls in order to avoid hooking into your ORMs domain object instantiation code (and forcing other code to instantiate through factories) and then suffering the overhead of injecting services into thousands/millions/billions/etc. of domain object instances that may not even end up needing their services.

The more I've thought about this over the last several days, the more I'm starting to think that the perf overhead of the more quote/unquote "elegant" approach using 100% DI may be worth avoiding at the cost of having to make Resolve calls. With that in mind I'll probably focus my efforts on cooking up nice, lean, (deferred!) field initializers so that at the very least the Resolve calls can be nicely centralized at the point where each service instance field is declared in each domain class.</description>
		<content:encoded><![CDATA[<p>Just to summarize your post modulo XPO specifics, here is what I&#8217;m gathering: Relative to the issues from earlier in the series, you&#8217;ve chosen to use a service locator (exposed via a layer supertype) for IoC within your domain, and continue to use use DI for IoC within your services.</p>
<p>This is a pretty common approach (historically the most common), getting us most of the way there, with the only main set of trade-offs being that your domain objects will have to make Resolve calls in order to avoid hooking into your ORMs domain object instantiation code (and forcing other code to instantiate through factories) and then suffering the overhead of injecting services into thousands/millions/billions/etc. of domain object instances that may not even end up needing their services.</p>
<p>The more I&#8217;ve thought about this over the last several days, the more I&#8217;m starting to think that the perf overhead of the more quote/unquote &#8220;elegant&#8221; approach using 100% DI may be worth avoiding at the cost of having to make Resolve calls. With that in mind I&#8217;ll probably focus my efforts on cooking up nice, lean, (deferred!) field initializers so that at the very least the Resolve calls can be nicely centralized at the point where each service instance field is declared in each domain class.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Rinat Abdullin</title>
		<link>http://rabdullin.com/how-to-implement-unit-testable-abstraction-and-reusable-domain-models-with-ioc-orm/#comment-425</link>
		<dc:creator>Rinat Abdullin</dc:creator>
		<pubDate>Mon, 10 Mar 2008 05:38:42 +0000</pubDate>
		<guid isPermaLink="false">http://rabdullin.com/how-to-implement-unit-testable-abstraction-and-reusable-domain-models-with-ioc-orm/#comment-425</guid>
		<description>Alex,

you are welcome.

Best regards,
Rinat</description>
		<content:encoded><![CDATA[<p>Alex,</p>
<p>you are welcome.</p>
<p>Best regards,<br />
Rinat</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Alex Hoffman</title>
		<link>http://rabdullin.com/how-to-implement-unit-testable-abstraction-and-reusable-domain-models-with-ioc-orm/#comment-424</link>
		<dc:creator>Alex Hoffman</dc:creator>
		<pubDate>Sun, 09 Mar 2008 21:03:43 +0000</pubDate>
		<guid isPermaLink="false">http://rabdullin.com/how-to-implement-unit-testable-abstraction-and-reusable-domain-models-with-ioc-orm/#comment-424</guid>
		<description>Rinat, many thanks for that.

-- Alex</description>
		<content:encoded><![CDATA[<p>Rinat, many thanks for that.</p>
<p>&#8211; Alex</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Rinat Abdullin</title>
		<link>http://rabdullin.com/how-to-implement-unit-testable-abstraction-and-reusable-domain-models-with-ioc-orm/#comment-423</link>
		<dc:creator>Rinat Abdullin</dc:creator>
		<pubDate>Sun, 09 Mar 2008 11:06:52 +0000</pubDate>
		<guid isPermaLink="false">http://rabdullin.com/how-to-implement-unit-testable-abstraction-and-reusable-domain-models-with-ioc-orm/#comment-423</guid>
		<description>Alex,

Sure. Please, take a look at the next post.

Additionally, I've posted a question about DXperience code sharing here:
http://community.devexpress.com//forums/p/62768/212865.aspx#212865

Best regards,
Rinat</description>
		<content:encoded><![CDATA[<p>Alex,</p>
<p>Sure. Please, take a look at the next post.</p>
<p>Additionally, I&#8217;ve posted a question about DXperience code sharing here:<br />
<a href="http://community.devexpress.com//forums/p/62768/212865.aspx#212865" rel="nofollow">http://community.devexpress.com//forums/p/62768/212865.aspx#212865</a></p>
<p>Best regards,<br />
Rinat</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Alex Hoffman</title>
		<link>http://rabdullin.com/how-to-implement-unit-testable-abstraction-and-reusable-domain-models-with-ioc-orm/#comment-420</link>
		<dc:creator>Alex Hoffman</dc:creator>
		<pubDate>Sun, 09 Mar 2008 00:44:54 +0000</pubDate>
		<guid isPermaLink="false">http://rabdullin.com/how-to-implement-unit-testable-abstraction-and-reusable-domain-models-with-ioc-orm/#comment-420</guid>
		<description>Many thanks, I've found the series culminating in this post really thought provoking.

One thing.  You mention... "Additionally we register the interface in slightly patched version of XPO’s ReflectionDictionary just to make it recognize the BO when it is asked to load its interface."

Is it possible to see the modified ReflectionDictionary code?

-- Alex</description>
		<content:encoded><![CDATA[<p>Many thanks, I&#8217;ve found the series culminating in this post really thought provoking.</p>
<p>One thing.  You mention&#8230; &#8220;Additionally we register the interface in slightly patched version of XPO’s ReflectionDictionary just to make it recognize the BO when it is asked to load its interface.&#8221;</p>
<p>Is it possible to see the modified ReflectionDictionary code?</p>
<p>&#8211; Alex</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: How to use ORM (XPO), IoC, C# 3.5 syntax, Linq and .NET 2.0 together? at Rinat Abdullin</title>
		<link>http://rabdullin.com/how-to-implement-unit-testable-abstraction-and-reusable-domain-models-with-ioc-orm/#comment-419</link>
		<dc:creator>How to use ORM (XPO), IoC, C# 3.5 syntax, Linq and .NET 2.0 together? at Rinat Abdullin</dc:creator>
		<pubDate>Sat, 08 Mar 2008 12:46:41 +0000</pubDate>
		<guid isPermaLink="false">http://rabdullin.com/how-to-implement-unit-testable-abstraction-and-reusable-domain-models-with-ioc-orm/#comment-419</guid>
		<description>[...] the ability to work with the actual object without any type casting)&#8230; you can check out the next post for [...]</description>
		<content:encoded><![CDATA[<p>[...] the ability to work with the actual object without any type casting)&#8230; you can check out the next post for [...]</p>
]]></content:encoded>
	</item>
</channel>
</rss>
