> Ok, you proved you're smart when it comes to deep OO stuff. ;)
thanks. ;)
> But really, would your boss be sympathetic if you told him it took you 4
> hours to get the data you need out of a db because you 'need' to do it
> properly, when he knows you could do it in less than an hour?
No, he wouldn't. That task is very simple, and there isn't really any
place for more than one level of abstraction (the gateway CFC).
<cfcomponent displayname="productgateway">
<cffunction name="doComplexQuery" ... >
...
<cfquery name="getResult">
SELECT ...
FROM ...
WHERE ....
</cfquery>
<cfreturn getResult />
</cffunction>
... other methods ...
</cfcomponent>
And once that's written:
<cfset result =
application.gatewayFactory.getInstance("product").doComplexQuery(argumentCollection
= args) />
<!--- do something with the 'result' recordset --->
The gateway factory's getInstance method is little more than
createObject("component", "com.domain.app.#name#gateway").init(dsn),
along with some instance caching so that the instances are reused.
As near as I can tell, that's as properly as it can be done, and it's
really friggin' simple. OO doesn't have to be complex, confusing,
obfuscating, or any other bad -ing. It merely provides a set of tools
to help solve problems. Pick the right tool for the job, and you'll
be set.
For example, complex business logic usually includes both retrieving
data and storing it. And it usually needs to be transactionally
processed. And you need to make sure that data validation is enforced
on EVERY update. And you want to cache information where possible for
speed. The list goes on. More complex problem, more complex
solution.
This type of scenario is where beans and DAOs come in handy, because
you can very easily build a generator that will take your DB schema
and create all the SQL for the CRUD operations, and leave yourself
just the business logic. And you can also very easily enforce hooks
up update/insert operations to ensure that validation ALWAYS runs,
because there is only one place to do an insert/update (the DAO)
rather than various SQL statements scattered around your application.
cheers,
barneyb
On 8/18/05, Munson, Jacob <[EMAIL PROTECTED]> wrote:
> Ok, you proved you're smart when it comes to deep OO stuff. ;)
>
> But really, would your boss be sympathetic if you told him it took you 4
> hours to get the data you need out of a db because you 'need' to do it
> properly, when he knows you could do it in less than an hour? And I
> don't agree that you will ever need to do that particular query again in
> a different app. If it were possible, why would we all need to know
> SQL? Why couldn't you just by a pre-canned database that did everything
> for you? Because you always have to write queries to solve business
> logic, and you can rarely take a complex query and plug it into a
> different app. I am /not/ saying that you should do it procedurally.
> OO is like normalizing a DB. You could go out the 5 or 6th level, but
> the experts agree that you never should, because the benefit of full
> normalization is outweighed by the cost it creates when you decide you
> actually need to use this database.
>
--
Barney Boisvert
[EMAIL PROTECTED]
360.319.6145
http://www.barneyb.com/
Got Gmail? I have 50 invites.
----------------------------------------------------------
You are subscribed to cfcdev. To unsubscribe, send an email to
[email protected] with the words 'unsubscribe cfcdev' as the subject of the
email.
CFCDev is run by CFCZone (www.cfczone.org) and supported by CFXHosting
(www.cfxhosting.com).
CFCDev is supported by New Atlanta, makers of BlueDragon
http://www.newatlanta.com/products/bluedragon/index.cfm
An archive of the CFCDev list is available at
www.mail-archive.com/[email protected]