Start with just a pure object model. Later you can pick it apart and patch up the bits that don't map real well to CF.
So, Projects have Tests. To me, that says that you have a Project class with an instance variable Tests. Tests is a collection that has methods like add, remove, find etc. The elements of the Tests collection are instances of the Test class. Instances of Test *may* have an instance variable Project, which points to the parent project - or may not. The benefit is flexibility in navigating between objects, the downside is another reference you have to manage. I tend to add these "back pointers" when and if I need them. Ditto for the tests->materials relationship. OK, so how do you do this in CF? The biggest mismatches are: 1) no built-in collection classes 2) the need to avoid instantiating lots of objects The usual workaround is to build the "collection object" as a (or with a) DAO (see also Gateway) and return a CF query from any method that might return more than one item. Within the DAO you can go crazy with naked SQL, or abstract the SQL with a framework, or both. Just keeping this brief for the moment, but ask for more detail and you shall receive. Jaime Metcher > -----Original Message----- > From: Richard White [mailto:[EMAIL PROTECTED] > Sent: Sunday, 25 May 2008 10:29 PM > To: CF-Talk > Subject: cfcs good practise > > > hi > > just wondering what you guys think about the structure of the > following cfc scenario, i am having difficulties picturing how to > best do it > > i have 3 core components to a system > > materials, projects, and tests > > they are relating as follows: > > each project contains various tests, and each test analyzes > various materials. the material can also be part of one or many > projects: for example they could have 1000 materials, 5 projects, > and each project has one or more tests analysing these materials > in different ways - a test could also be a part of one or more projects > > in the database i have 5 tables to represent this: > > projects, tests, and materials hold their individual information, > then they are linked by 2 tables: > > projecttests (include primary keys from these tables) > testmaterials (include primary keys from these tables) > > this is working fine but when i try to think of this in terms of > cfc's then i get a bit lost, as i am new to working with cfc's so > would appreciate any advice on what you guys would do. > > i am thinking there would be a cfc called project, one called > test, and one called materials. but then what would i call in > order to get the testmaterials for a specific test etc... > > i know i can normally query the database table to get that > information but i am wanting to get to grips with how to best use > the cfc's and wonder if you guys have any pointers > > also, if i wanted to get information about multiple tests, i.e. > their test locations, then would i need to create a collection of > cfc objects in order to store this data > > i know this is a lengthy question but i feel if i can get my head > around these concepts then i would understand cfc's alot more > > thanks again for your help > > richard > > > > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date Get the Free Trial http://ad.doubleclick.net/clk;192386516;25150098;k Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:306029 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4

