<?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"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Designing an OO Backend</title>
	<atom:link href="http://www.barneyb.com/barneyblog/2005/09/25/designing-an-oo-backend/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.barneyb.com/barneyblog/2005/09/25/designing-an-oo-backend/</link>
	<description>Thoughts, rants, and even some code from the mind of Barney Boisvert.</description>
	<lastBuildDate>Thu, 11 Sep 2014 09:58:12 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Tuggle</title>
		<link>https://www.barneyb.com/barneyblog/2005/09/25/designing-an-oo-backend/comment-page-1/#comment-253</link>
		<dc:creator>Tuggle</dc:creator>
		<pubDate>Sat, 12 Aug 2006 10:53:10 +0000</pubDate>
		<guid isPermaLink="false">http://barneyb.com/barneyblog/?p=122#comment-253</guid>
		<description>I also have been raised on storing services in the application scope. I see what you mean about cumbersomeness, I guess it&#039;s a trade off between readability and maintainability (a real word?). It&#039;s pretty rare that those two things compete!

This is a great article (even um, a year later) thanks Barney. :)

</description>
		<content:encoded><![CDATA[<p>I also have been raised on storing services in the application scope. I see what you mean about cumbersomeness, I guess it's a trade off between readability and maintainability (a real word?). It's pretty rare that those two things compete!</p>
<p>This is a great article (even um, a year later) thanks Barney. :)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Barney</title>
		<link>https://www.barneyb.com/barneyblog/2005/09/25/designing-an-oo-backend/comment-page-1/#comment-252</link>
		<dc:creator>Barney</dc:creator>
		<pubDate>Tue, 27 Sep 2005 13:59:53 +0000</pubDate>
		<guid isPermaLink="false">http://barneyb.com/barneyblog/?p=122#comment-252</guid>
		<description>Steve,

The main pitfall with having all the services directly in the application scope is that you end up having to pass a lot of object references around your application.  Yes, it&#039;s more clear in the sense that the object coupling is explicitly laid, but it&#039;s also really cumbersome to deal with.

In the main app I&#039;ve got, most of my services only require references to one or two other services (there are perhaps 40 services total), but there are a few that require 10-15 other service references, and one that requires more than 30.  I could pass those around individually, but passing a single factory object and allowing the object to get what it needs, when it needs it, makes for much easier to maintain code.

The other advantage of a service factory (or any sort of factory, really), is that it lets you encapsulate the initialization of the objects.  Right now, you initialize into the application scope, and pass references (or use the directly), because you can&#039;t initialize them any other way.  With a factory, you can &quot;initialize&quot; a new instance at any time.  The factory isn&#039;t actually going to create a new object (at least if it&#039;s a singleton), but there&#039;s no way for the calling code to know that.

Bottom line, I&#039;d say a factory is better encapsulated, even if the coupling between objects isn&#039;t as clearly documented but the constructor parameters.</description>
		<content:encoded><![CDATA[<p>Steve,</p>
<p>The main pitfall with having all the services directly in the application scope is that you end up having to pass a lot of object references around your application.  Yes, it's more clear in the sense that the object coupling is explicitly laid, but it's also really cumbersome to deal with.</p>
<p>In the main app I've got, most of my services only require references to one or two other services (there are perhaps 40 services total), but there are a few that require 10-15 other service references, and one that requires more than 30.  I could pass those around individually, but passing a single factory object and allowing the object to get what it needs, when it needs it, makes for much easier to maintain code.</p>
<p>The other advantage of a service factory (or any sort of factory, really), is that it lets you encapsulate the initialization of the objects.  Right now, you initialize into the application scope, and pass references (or use the directly), because you can't initialize them any other way.  With a factory, you can "initialize" a new instance at any time.  The factory isn't actually going to create a new object (at least if it's a singleton), but there's no way for the calling code to know that.</p>
<p>Bottom line, I'd say a factory is better encapsulated, even if the coupling between objects isn't as clearly documented but the constructor parameters.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Steve Bryant</title>
		<link>https://www.barneyb.com/barneyblog/2005/09/25/designing-an-oo-backend/comment-page-1/#comment-251</link>
		<dc:creator>Steve Bryant</dc:creator>
		<pubDate>Tue, 27 Sep 2005 10:39:25 +0000</pubDate>
		<guid isPermaLink="false">http://barneyb.com/barneyblog/?p=122#comment-251</guid>
		<description>Barney,

Great post! I agree with Joe that it would make a great CFDJ article.

You mentioned that don&#039;t recommend using application-scoped service objects for large applications. That is exactly what I am doing right now, so I would love to know what the pitfalls of that approach are and any suggestions you might have.

I would love to see more information on how you use service factories.

One thing I am having a hard time getting my head around is how you call objects from the service factory without breaking encapsulation. Right now, I pass in any component that I need to a component that uses it. This makes the dependency clear. It seems like those dependencies would become much less clear when calling service objects from the factory.

Sorry if I overloaded you with too many questions.

Thanks for the great post!</description>
		<content:encoded><![CDATA[<p>Barney,</p>
<p>Great post! I agree with Joe that it would make a great CFDJ article.</p>
<p>You mentioned that don't recommend using application-scoped service objects for large applications. That is exactly what I am doing right now, so I would love to know what the pitfalls of that approach are and any suggestions you might have.</p>
<p>I would love to see more information on how you use service factories.</p>
<p>One thing I am having a hard time getting my head around is how you call objects from the service factory without breaking encapsulation. Right now, I pass in any component that I need to a component that uses it. This makes the dependency clear. It seems like those dependencies would become much less clear when calling service objects from the factory.</p>
<p>Sorry if I overloaded you with too many questions.</p>
<p>Thanks for the great post!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Joe Rinehart</title>
		<link>https://www.barneyb.com/barneyblog/2005/09/25/designing-an-oo-backend/comment-page-1/#comment-250</link>
		<dc:creator>Joe Rinehart</dc:creator>
		<pubDate>Tue, 27 Sep 2005 09:39:43 +0000</pubDate>
		<guid isPermaLink="false">http://barneyb.com/barneyblog/?p=122#comment-250</guid>
		<description>Hey man,

This rocks.  Ever thought about submitting it to Simon Horwith for a CFDJ article?

-Joe</description>
		<content:encoded><![CDATA[<p>Hey man,</p>
<p>This rocks.  Ever thought about submitting it to Simon Horwith for a CFDJ article?</p>
<p>-Joe</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Raymond Camden</title>
		<link>https://www.barneyb.com/barneyblog/2005/09/25/designing-an-oo-backend/comment-page-1/#comment-249</link>
		<dc:creator>Raymond Camden</dc:creator>
		<pubDate>Mon, 26 Sep 2005 12:48:43 +0000</pubDate>
		<guid isPermaLink="false">http://barneyb.com/barneyblog/?p=122#comment-249</guid>
		<description>Not to put more work on your plate, but you should offer a simple example of this as well, in real code. I think it would be useful. Of course, I don&#039;t mean a full implementation, ie, addUser should be empty, but just the shell.</description>
		<content:encoded><![CDATA[<p>Not to put more work on your plate, but you should offer a simple example of this as well, in real code. I think it would be useful. Of course, I don't mean a full implementation, ie, addUser should be empty, but just the shell.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Scott Stroz</title>
		<link>https://www.barneyb.com/barneyblog/2005/09/25/designing-an-oo-backend/comment-page-1/#comment-248</link>
		<dc:creator>Scott Stroz</dc:creator>
		<pubDate>Mon, 26 Sep 2005 10:29:11 +0000</pubDate>
		<guid isPermaLink="false">http://barneyb.com/barneyblog/?p=122#comment-248</guid>
		<description>Barney - 

Between you and Joe Rinehart, I may actaully &#039;get&#039; OOP after a while.

Great job!</description>
		<content:encoded><![CDATA[<p>Barney &#8211; </p>
<p>Between you and Joe Rinehart, I may actaully 'get' OOP after a while.</p>
<p>Great job!</p>
]]></content:encoded>
	</item>
</channel>
</rss>
