I’m modeling my Objects after my database structure.  Each object represents a table.  Whenever I instantiate the object I pull all the information about the object together.  I think this is a little overkill; I’m just playing around to see what I can do with it. 

 

What rules of thumb/guidelines do you go by when modeling your objects?  Do you base it upon a table structure, or perhaps how the objects interact with each other?  My initial guidelines are something Hal Helms mentioned about objects.  He said to the effect that an object should contain everything it knows about itself.  For instance, a person knows his/her name, age, birth date, sex, etc.  So, I instantiate an object by passing its unique ID into a method.  I then go through the database structure and pull the data I can “find” for that ID into the object.  This seems like a lot of overhead because I have to pull all of this data together for each instantiation.  I may only use part of the data available to me at any one point in my application.  How does CF manage the data pulled together for an object?  Is it stored in memory?

 

Is there a better way to model your objects?  It seems like a natural fit to model it against your database structure, but it seems like too much overhead: why not just query against the table when you need the data?  Anyways, if anyone has any advice on better ways to model I would appreciate their advice.

 

Thanks -

 

Tom Schreck

817-252-4900

[EMAIL PROTECTED]

 

I have not failed.  I've found 10,000 ways that won't work.

 

- Thomas Edison

 

-----Original Message-----
From: Billy Cravens [mailto:[EMAIL PROTECTED]]
Sent:
Monday, September 23, 2002 8:09 PM
To: [EMAIL PROTECTED]
Subject: RE: CFC Question

 

From a technical standpoint, there’s nothing wrong with what you’re doing (perhaps each instance of an object has a performance hit, but I doubt it’s significant).

 

However, I would focus on your objects from an abstract view.  Are your 2 objects working on different “items”?

 

For example:

 

1)       I have an “orders” object.  I want to look at a particular order, and return a recordset containing all items in that order.  In this instance, I would only have a single object, “orders”, since everything is so closely related.

2)       I want to pull a recordset containing all orders placed by a certain customer.  In this situation, you might have a customers object, that interacts with an orders object. 

 

I think we will see many different approaches for interfacing with CFCs: the most basic encapsulation, replacements for custom tags, etc.  However, I think the true power of CFC’s come when you use them to model the real world.

 

**************************

Billy Cravens

Web and Software consulting

www.Architechx.com

 

-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] On Behalf Of Schreck, Tom
Sent:
Monday, September 23, 2002 11:57 AM
To: [EMAIL PROTECTED]
Subject: CFC Question

 

I’ve been experimenting with CFCs and am excited about the potential.  I see how it’s a switch in perspective of how you model your application.  I’ve created an object, Object A, which has a 1-to-many relationship with another object, Object B.  I created a function of Object A which returns a recordset of all records from Object B related to Object A.  So, whenever I instantiate Object A, I have available to me all records related to Object A that belong to Object B.  This is stored in Object A as this.ListObjectB.  Is this good practice?  Where does all of the information about an object get stored when you instantiate it?  Should you “store” a recordset of data in an object, or just call a function to return the recordset whenever you need it?  Does anyone have guidelines/best practices for working with CFC?

 

Thanks -

 

Tom Schreck

817-252-4900

[EMAIL PROTECTED]

 

I have not failed.  I've found 10,000 ways that won't work.

 

- Thomas Edison

 

Reply via email to