This content has been marked as final. Show 4 replies
Your title says cfc but your narrative sounds like database design. For me, a cfc is nothing more than a way to create re-useable code. Anything beyond that is an unnecessary complication.
David, depending how you create your objects, nothing prevents you from doing both.
customer = getCustomerById(n);
workOrderIterator = customer.getWordOrderIterator();
workOrder = workOrderIterator.getNext();
workOrder = getWorkOrderById(n);
customer = workOrder.getCustomer();
There are some good frameworks to help you with this. ColdSpring will allow you to wire your objects together thru dependency injection, and Reactor or Transfer can help you create your objects from your database.
Dan, a CFC is an object, not just a better-organized spaghetti code. ColdFusion is transitioning to be a nice Object Oriented Language so please try not to confuse people heading in the right direction.
Thanks Rob. This is exactly where I was headed with this.
On initial population from database data, I will want to make sure to have already created a WorkOrders collection reference within the customer object. This way, I can populate both the general WorkOrders collection and the specific Customer WorkOrders colelction with the same memory referenced object.
I recognize that Coldfusion is not a stict OO language but by developing as closely to the OO paradigm, I will benefit by easily migrating into other OO languages. I must admit, I orginally developed CFC's to act more like UDF's until I learned true OO development. I have even separated all database code from my base objects. I am certain I will always have more to learn but I least I am using CFC's as objects.
Mark Mandel presented his Transfer ORM this afternoon. I highly recommend you check out this Breeze Recording. He covers using an ORM for your CRUD needs, including setting up relations. Transfer can easily create your objects including your oneToMany and manyToOne relations.
Basically Transfer takes care of DAO, so all you have to do is to create your service layer, and well, gateways if needed. Feel free to drop me an email if you need more details: rob[at]robgonda[dot]com.