On 4/19/06, Bryan Stevenson <[EMAIL PROTECTED]> wrote:
> With the exception of the "adding a new field in the DB and it's avaialable
> evrywhere" bit, the other examples are easily handles by CFCs....one method to
> update...another to insert...they do different things...just like your 
> example:

First of all, you can write CFCs that reflect the database to
dynamically find out the content. So that's not all that amazing from
a CF perspective. Butyou're really missing a lot about what's going on
under the hood.

Here's an example of an ActiveRecord class that models an order

class Order < ActiveRecord::Base
end

That's it, two lines of code (hardly worth firing up the command line
to generate it...)

So what can I do now that I have those two lines? (This is
*completely* independent of Rails for what it's worth -- I can do this
from a Ruby command line since ActiveRecord is just another class. )

First of all, the class reflects the db to find all the columns and their types.
Now, some code

Order.find(10)

I just found order with the key=10. No code, no sql. That function is
built-in and knows what to do.

Though to be fair, I should add a few lines to initialize the db
connection, which would be taken care of in the Rails environment.

Now all the orders that are from virginia and a few variations

Order.find(:all, :conditions => "state='va'")
Order.find(:all, :conditions => "state='va', and firstname='bob'")
Order.find(:all, :conditions => "state='va' and total>1000")

of course all the quoting, escaping, and sql-injection is handled for
you. And it's easy to paramaterize to the params[] hash (similar to
attributes scope in cf) if you're in Rails.

Order.find(:all, :conditions => [state = :state and total > :total",params)

Remember our class that provides this looks like this

class Order < ActiveRecord::Base
end

I could also do this

Order.find_by_state("Virginia")

Note that I'm not adding that method to the code. It just gets figured
out. I can do this too

Order.find_by_state_and_firstname("Virginia","Bob")

Still, by ActiveRecord class is two lines of boilerplate. And we
haven't gotten to the CUD parts of CRUD yet. Or the C and V parts of
MVC. Or testing/etc.

What does the equivalent CFC look like?

I do know Arf! can do a little of this, and that Reactor will generate
some of this as well. And most of this _could_ be duplicated with a
lot of hard work in CF.

Of course I *do* still have to write the date range validation by hand :)

> Same goes for validation on Insert/update...seperate methods to handle
> them....so no bonus with RoRo there.

Except that you *don't have to write the methods* in most cases, or at
least you write very little.

> Now the "add a field" bit you mentioned....well just because "everything" 
> knows
> about the new field does NOT mean that "everything" knows what to do with
> it.....so back to having to add custom code tweaks to make "everything" handle
> that new field correctly.

Sure it does. You can CRUD it. All of the objects (even aggregate
objects) automatically know what to do with it. Etc, etc.

> No sale here....try the Vogons..they're big on super highways...mabye they'll
> see the light that I cannot ;-)

That's fine -- you don't have to use Rails. But I think you're
discounting it without knowing a whole lot about what it really does
-- watching the "Rails in 15m" intro doesn't give you much to go on
compared to working throught the Rails book (Agile Web Dev w/ Rails)
or building a couple of real apps.

Heck, I'm annoyed that I have to write XML to configure all the CF
frameworks after I come back from a week or two in YAML land.. but
that's a completely different thread ;)
--
John Paul Ashenfelter
CTO/Transitionpoint
(blog) http://www.ashenfelter.com
(email) [EMAIL PROTECTED]

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Message: http://www.houseoffusion.com/lists.cfm/link=i:4:238241
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Donations & Support: http://www.houseoffusion.com/tiny.cfm/54

Reply via email to