<?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: Impetus for an OO Backend</title>
	<atom:link href="http://www.barneyb.com/barneyblog/2005/09/11/impetus-for-an-oo-backend/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.barneyb.com/barneyblog/2005/09/11/impetus-for-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: Barney</title>
		<link>https://www.barneyb.com/barneyblog/2005/09/11/impetus-for-an-oo-backend/comment-page-1/#comment-234</link>
		<dc:creator>Barney</dc:creator>
		<pubDate>Mon, 24 Jul 2006 13:49:40 +0000</pubDate>
		<guid isPermaLink="false">http://barneyb.com/barneyblog/?p=116#comment-234</guid>
		<description>Rob,

Yeah, in general, I prefer to keep my gateways and DAO&#039;s separate.  So DAO&#039;s operate on a single instance of a business entity, and gateways are basically collections of SELECT statements that don&#039;t return objects.  Most of the time they return recordsets/queries, but some return number or strings (like a getXXXCount style method).

Regarding services/managers, it&#039;s mostly personal preference.  I happen to generate my managers automatically, so having the services separate (which are largely hand-written) makes future regeneration a lot easier.

In the great scheme of things, the specifics don&#039;t matter too much.  As long as you&#039;re encapsulating all the needed functionality in a logical and consistent way, it&#039;s hard to really be &quot;wrong&quot;.
</description>
		<content:encoded><![CDATA[<p>Rob,</p>
<p>Yeah, in general, I prefer to keep my gateways and DAO's separate.  So DAO's operate on a single instance of a business entity, and gateways are basically collections of SELECT statements that don't return objects.  Most of the time they return recordsets/queries, but some return number or strings (like a getXXXCount style method).</p>
<p>Regarding services/managers, it's mostly personal preference.  I happen to generate my managers automatically, so having the services separate (which are largely hand-written) makes future regeneration a lot easier.</p>
<p>In the great scheme of things, the specifics don't matter too much.  As long as you're encapsulating all the needed functionality in a logical and consistent way, it's hard to really be "wrong".</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Rob Pilic</title>
		<link>https://www.barneyb.com/barneyblog/2005/09/11/impetus-for-an-oo-backend/comment-page-1/#comment-233</link>
		<dc:creator>Rob Pilic</dc:creator>
		<pubDate>Thu, 20 Jul 2006 16:39:43 +0000</pubDate>
		<guid isPermaLink="false">http://barneyb.com/barneyblog/?p=116#comment-233</guid>
		<description>Barney, I just read this post and found it tremendously helpful as I am trying to wrap my head around OO concepts. I am curious if you still use gateways for all your non-entity queries. The way I&#039;ve read gateways being used is for aggregate queries, and sometimes just to return a query object instead of a collection of bean objects. Also I see you use managers AND services, where managers just manage the beans and services handle all the business logic - the way I&#039;ve previously read is to have service objects handle both. I guess it&#039;s a matter of preference but I wonder if you had any thoughts on it. Again thanks for the great post.</description>
		<content:encoded><![CDATA[<p>Barney, I just read this post and found it tremendously helpful as I am trying to wrap my head around OO concepts. I am curious if you still use gateways for all your non-entity queries. The way I've read gateways being used is for aggregate queries, and sometimes just to return a query object instead of a collection of bean objects. Also I see you use managers AND services, where managers just manage the beans and services handle all the business logic &#8211; the way I've previously read is to have service objects handle both. I guess it's a matter of preference but I wonder if you had any thoughts on it. Again thanks for the great post.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dharma</title>
		<link>https://www.barneyb.com/barneyblog/2005/09/11/impetus-for-an-oo-backend/comment-page-1/#comment-232</link>
		<dc:creator>Dharma</dc:creator>
		<pubDate>Tue, 23 May 2006 05:19:14 +0000</pubDate>
		<guid isPermaLink="false">http://barneyb.com/barneyblog/?p=116#comment-232</guid>
		<description>difference b/w DAO and BO</description>
		<content:encoded><![CDATA[<p>difference b/w DAO and BO</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Sam Clement</title>
		<link>https://www.barneyb.com/barneyblog/2005/09/11/impetus-for-an-oo-backend/comment-page-1/#comment-231</link>
		<dc:creator>Sam Clement</dc:creator>
		<pubDate>Wed, 12 Oct 2005 02:02:23 +0000</pubDate>
		<guid isPermaLink="false">http://barneyb.com/barneyblog/?p=116#comment-231</guid>
		<description>I just got round to reading this after bookmarking it long ago. Great post!  I always enjoy reading about your insights into coding.</description>
		<content:encoded><![CDATA[<p>I just got round to reading this after bookmarking it long ago. Great post!  I always enjoy reading about your insights into coding.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mark Mandel</title>
		<link>https://www.barneyb.com/barneyblog/2005/09/11/impetus-for-an-oo-backend/comment-page-1/#comment-230</link>
		<dc:creator>Mark Mandel</dc:creator>
		<pubDate>Thu, 15 Sep 2005 00:17:33 +0000</pubDate>
		<guid isPermaLink="false">http://barneyb.com/barneyblog/?p=116#comment-230</guid>
		<description>Whoops! Sorry Barney!
I was obviously having a bad name day.

Thanks for that - I&#039;m interested to see how differnt people organise their CFCs.</description>
		<content:encoded><![CDATA[<p>Whoops! Sorry Barney!<br />
I was obviously having a bad name day.</p>
<p>Thanks for that &#8211; I'm interested to see how differnt people organise their CFCs.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Barney</title>
		<link>https://www.barneyb.com/barneyblog/2005/09/11/impetus-for-an-oo-backend/comment-page-1/#comment-229</link>
		<dc:creator>Barney</dc:creator>
		<pubDate>Wed, 14 Sep 2005 18:16:48 +0000</pubDate>
		<guid isPermaLink="false">http://barneyb.com/barneyblog/?p=116#comment-229</guid>
		<description>Mark,

I&#039;m actually Barney, not Barry, but it&#039;s all good.  I use a single mapping (/com/domain) that points to the ${approot}/cfcs/com/domain directory, and then branch from there.  I usually put my entity objects in a separate package (like com.domain.data), and then put my non-entity objects in other packages.  By entity objects, I mean all the per-entity stuff, so BOs, DAOs, managers, and some gateways and services.

Just for reference, I also have a /ct/domain mapping that points to ${approot}/tags for all my custom tags.  So every non-trivial app I build uses two CF mappings, and no external custom tags.</description>
		<content:encoded><![CDATA[<p>Mark,</p>
<p>I'm actually Barney, not Barry, but it's all good.  I use a single mapping (/com/domain) that points to the ${approot}/cfcs/com/domain directory, and then branch from there.  I usually put my entity objects in a separate package (like com.domain.data), and then put my non-entity objects in other packages.  By entity objects, I mean all the per-entity stuff, so BOs, DAOs, managers, and some gateways and services.</p>
<p>Just for reference, I also have a /ct/domain mapping that points to ${approot}/tags for all my custom tags.  So every non-trivial app I build uses two CF mappings, and no external custom tags.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mark Mandel</title>
		<link>https://www.barneyb.com/barneyblog/2005/09/11/impetus-for-an-oo-backend/comment-page-1/#comment-228</link>
		<dc:creator>Mark Mandel</dc:creator>
		<pubDate>Wed, 14 Sep 2005 02:14:08 +0000</pubDate>
		<guid isPermaLink="false">http://barneyb.com/barneyblog/?p=116#comment-228</guid>
		<description>Barry - fantastic post!

This actually looks very similar to how I&#039;m currently setting up my applications. So either I now feel like I&#039;m on the right track, or we&#039;re both crazy ;o) 

I&#039;d be also interested to know how you setup your CFCs in terms of directories, and how you decided to organise your CFC roots - did you place them all in a directory at the root of your application, or set up a mapping etc?

I&#039;ve refactored my current app (my website v2.0) about 3/4 times trying to work out what the best/favourite way to structure CFCs was, and I still can&#039;t decide. :o/</description>
		<content:encoded><![CDATA[<p>Barry &#8211; fantastic post!</p>
<p>This actually looks very similar to how I'm currently setting up my applications. So either I now feel like I'm on the right track, or we're both crazy ;o) </p>
<p>I'd be also interested to know how you setup your CFCs in terms of directories, and how you decided to organise your CFC roots &#8211; did you place them all in a directory at the root of your application, or set up a mapping etc?</p>
<p>I've refactored my current app (my website v2.0) about 3/4 times trying to work out what the best/favourite way to structure CFCs was, and I still can't decide. :o/</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Barney</title>
		<link>https://www.barneyb.com/barneyblog/2005/09/11/impetus-for-an-oo-backend/comment-page-1/#comment-227</link>
		<dc:creator>Barney</dc:creator>
		<pubDate>Tue, 13 Sep 2005 22:54:13 +0000</pubDate>
		<guid isPermaLink="false">http://barneyb.com/barneyblog/?p=116#comment-227</guid>
		<description>Jared,

Just to be clear, you have several read() methods in your DAO that take different parameters that can uniquely identify an entity?  I have to say I never considered doing it that way, rather having my DAOs be exclusively primary key based, and having lookup methods (in my gateway) that will translate unique identifier X into the corresponding primary key, which is then use for the DAO.  It&#039;s also a lot easier to generate my DAOs automatically that way, though if you have the unique keys tagged in your database, I suppose you could generate the other read() methods as well.  Like I said in my post, the primary impetus for the DAOs was to never again write entity persistance queries, so autogeneratability is of great import.

For the BO (bean) population stuff, I use a manager (or factory) for this.  So I call getUserById() or whatever, which instantiates a user BO, sets the id field on it, and passes it to the DAO to populate (a SELECT query and a bunch of CFSETs).  Then the manager returns it to whomever requested it.  My DAOs are implementation details of the managers; there&#039;s no other way to get a reference to a DAO.  Managers handle creation and persistance operations for entities, and that&#039;s all they do.  They happen to use DAOs to do it.  Makes sense to me, but I&#039;ve been called crazy before.  ;)</description>
		<content:encoded><![CDATA[<p>Jared,</p>
<p>Just to be clear, you have several read() methods in your DAO that take different parameters that can uniquely identify an entity?  I have to say I never considered doing it that way, rather having my DAOs be exclusively primary key based, and having lookup methods (in my gateway) that will translate unique identifier X into the corresponding primary key, which is then use for the DAO.  It's also a lot easier to generate my DAOs automatically that way, though if you have the unique keys tagged in your database, I suppose you could generate the other read() methods as well.  Like I said in my post, the primary impetus for the DAOs was to never again write entity persistance queries, so autogeneratability is of great import.</p>
<p>For the BO (bean) population stuff, I use a manager (or factory) for this.  So I call getUserById() or whatever, which instantiates a user BO, sets the id field on it, and passes it to the DAO to populate (a SELECT query and a bunch of CFSETs).  Then the manager returns it to whomever requested it.  My DAOs are implementation details of the managers; there's no other way to get a reference to a DAO.  Managers handle creation and persistance operations for entities, and that's all they do.  They happen to use DAOs to do it.  Makes sense to me, but I've been called crazy before.  ;)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jared Rypka-Hauer</title>
		<link>https://www.barneyb.com/barneyblog/2005/09/11/impetus-for-an-oo-backend/comment-page-1/#comment-226</link>
		<dc:creator>Jared Rypka-Hauer</dc:creator>
		<pubDate>Tue, 13 Sep 2005 16:43:30 +0000</pubDate>
		<guid isPermaLink="false">http://barneyb.com/barneyblog/?p=116#comment-226</guid>
		<description>Hey Barney...

Good stuff.

It&#039;s interesting to see the differences between FB3, FB4.1, and MG/M2. Since the controller/listener classes in the latter are CFCs, there&#039;s many choices in how to use CFCs for the services, logic, and persistence layers. It&#039;s the same thing only different, if you get my meaning. ;)

In the past, I&#039;ve tended to use a simple composite relationship between DAO/Gateway and the controller... in the controller just doing a cfset thisDAO = createObject(...). For simple things it&#039;s still a fine way to go. However I&#039;ve also been experimenting with more elegant ways to expose the model to the controller, either with something like ColdSpring or ChiliBeans (which is built in to ModelGlue) to generate collection instances that hold the DAO/GW instances. I find myself using collection objects a LOT.

The thing that&#039;s pestering me the most at this point is the overlap of code between some of the read methods in my DAOs (by email, by ID, by email+password) which makes several queries to maintain. I&#039;ve also been looking at breaking code into several controllers, which can create a code duplication problem (in this case, a good time for inheritance).

So I appreciate you putting this out here and giving us a point around which to discuss these issues. :)

One question though... I&#039;ve read a couple things lately that indicate some people are returning populated user beans from a userDAO.read() method. Personally I think it&#039;s messy. Personally I tend to think that calling a UserService, which executes userDAO.read() and then creates a bean and populates it is cleaner and more flexible. Granted there&#039;s no &quot;rules&quot; on this sort of implementation-specific situation, but what&#039;s your feeling on the issue?

For my part, right now I have a controller that calls a DAO method it gets from a service and passes that record to it&#039;s own private method to generate a user bean from the query. It&#039;s not the best and will change, but I like it better than blending factories and CRUD in a DAO.</description>
		<content:encoded><![CDATA[<p>Hey Barney&#8230;</p>
<p>Good stuff.</p>
<p>It's interesting to see the differences between FB3, FB4.1, and MG/M2. Since the controller/listener classes in the latter are CFCs, there's many choices in how to use CFCs for the services, logic, and persistence layers. It's the same thing only different, if you get my meaning. ;)</p>
<p>In the past, I've tended to use a simple composite relationship between DAO/Gateway and the controller&#8230; in the controller just doing a cfset thisDAO = createObject(&#8230;). For simple things it's still a fine way to go. However I've also been experimenting with more elegant ways to expose the model to the controller, either with something like ColdSpring or ChiliBeans (which is built in to ModelGlue) to generate collection instances that hold the DAO/GW instances. I find myself using collection objects a LOT.</p>
<p>The thing that's pestering me the most at this point is the overlap of code between some of the read methods in my DAOs (by email, by ID, by email+password) which makes several queries to maintain. I've also been looking at breaking code into several controllers, which can create a code duplication problem (in this case, a good time for inheritance).</p>
<p>So I appreciate you putting this out here and giving us a point around which to discuss these issues. :)</p>
<p>One question though&#8230; I've read a couple things lately that indicate some people are returning populated user beans from a userDAO.read() method. Personally I think it's messy. Personally I tend to think that calling a UserService, which executes userDAO.read() and then creates a bean and populates it is cleaner and more flexible. Granted there's no "rules" on this sort of implementation-specific situation, but what's your feeling on the issue?</p>
<p>For my part, right now I have a controller that calls a DAO method it gets from a service and passes that record to it's own private method to generate a user bean from the query. It's not the best and will change, but I like it better than blending factories and CRUD in a DAO.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Barney</title>
		<link>https://www.barneyb.com/barneyblog/2005/09/11/impetus-for-an-oo-backend/comment-page-1/#comment-225</link>
		<dc:creator>Barney</dc:creator>
		<pubDate>Mon, 12 Sep 2005 01:36:44 +0000</pubDate>
		<guid isPermaLink="false">http://barneyb.com/barneyblog/?p=116#comment-225</guid>
		<description>Roger,

First and foremost, it&#039;s what the app&#039;s already written with, and none of those other frameworks bring enough to the table to make it worth the switch.  I haven&#039;t counted in a while, but it&#039;s probably about 50 circuits, ranging between 8-10 and 40-50 fuseactions in each one.

But even if I were writing from scratch, I&#039;d probably still stick with FB3, because the app is so complex but the UI isn&#039;t.  Even FB4 (which I helped write) is complex to use for simple tasks, and a thin UI layer doesn&#039;t warrant that complexity.  If you have a UI that requires a lot of page assembly (i.e. complex layouts/portals), then FB4 is a much better choice, but I don&#039;t have that need in this particular app.

It&#039;s worth mentioning that when I say &quot;FB3&quot;, I don&#039;t really mean your standard run-of-the-mill FB3.  I&#039;ve made a couple tweaks to the core (minor ones, like requiring fbx_Switch in every circuit), but most important is the &#039;do&#039; UDF, which emulates FB4&#039;s DO verb, but without the performance benefits.</description>
		<content:encoded><![CDATA[<p>Roger,</p>
<p>First and foremost, it's what the app's already written with, and none of those other frameworks bring enough to the table to make it worth the switch.  I haven't counted in a while, but it's probably about 50 circuits, ranging between 8-10 and 40-50 fuseactions in each one.</p>
<p>But even if I were writing from scratch, I'd probably still stick with FB3, because the app is so complex but the UI isn't.  Even FB4 (which I helped write) is complex to use for simple tasks, and a thin UI layer doesn't warrant that complexity.  If you have a UI that requires a lot of page assembly (i.e. complex layouts/portals), then FB4 is a much better choice, but I don't have that need in this particular app.</p>
<p>It's worth mentioning that when I say "FB3&#8243;, I don't really mean your standard run-of-the-mill FB3.  I've made a couple tweaks to the core (minor ones, like requiring fbx_Switch in every circuit), but most important is the 'do' UDF, which emulates FB4's DO verb, but without the performance benefits.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
