Hi Nick,

Method #2 will definitely be faster to build, easier to maintain and quicker
to load - HOWEVER - it is generally considered bad practice to do it in such
a way because you will lose valuable flexibility and introspection. For
example:

- often you will need custom processing when GET'ing or SET'ing properties
that wouldn't be possible with generic getters and setters.

- often properties don't actually exist and are calculated from other
properties

- Sometimes you don't want to expose ALL properties for GET'ing, SET'ing -
sometimes variables are for internal use only.

- it is clearer and more informative to look at a CFC with all possible
GET/SET methods explicitly defined, rather than guessing which properties
are GET'able/SET'able

- as for reducing maintenance when adding a property, you don't really save
that much time because you still have to edit the CFC, you just save on a
quick copy/paste of the getter/setter

I personally just use a code generator that reads my DB and pumps out all
the Getters and Setters so time-consumption is 0.

Hope this helps,
Baz




-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf
Of Nick Han
Sent: Thursday, January 19, 2006 1:22 PM
To: [email protected]
Subject: [CFCDev] Bean and CFC question

I like the use of beans as a bridge to transport data between the
presentation layer (forms) and business objects, which do all the
database interactions.  Constructing beans can be a repetitive and
time-consuming task, so lately I have been toying around with a
different transfer object that acts like a bean, but it is easier to
build, add on, and maintain.  I would like your opinions on it and
whether it is a good or bad.

Instead of writing a bean that has getters and setters and will
interface like this:


<cfset objFilter=CreateObject("component","reportFilter").init(dsn)>

Method #1

<cfset objFilter.setFirstname="John">
<cfset objFilter.setLastName="Doe">

I then pass this objFilter into my business object.  Inside the business
object, the values in the filter object will be accessed like this:

Arguments.objFilter.getFirstName();
Arguments.objFilter.getLastName();

Method #2

I have been toying with this method:

<cfset objFilter.add('firstname','John')>
<cfset objFilter.add('lastname','Doe')>

Inside my business object, I would access the values of the objFilter
like this:

Arguments.objFilter.getValue('lastName')
Arguments.objFilter.getValue('firstname')

The advantage I see in Method 2 is that as the business object requires
additional filter parameters, the objFilter object doesn't require the
maintenance of adding more getters or setters. 

Any thought on the good or bad on Method #2 is appreciated.  Thanks.


----------------------------------------------------------
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).

An archive of the CFCDev list is available at
www.mail-archive.com/[email protected]





----------------------------------------------------------
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).

An archive of the CFCDev list is available at 
www.mail-archive.com/[email protected]


Reply via email to