The theory behind getters and setters is abstraction. You are not
"supposed" to deal with the data directly nor are you "supposed" to know
how the data is stored and how the object works.  You create an object
and let it do the work for you.  Getters and Setters hide implementation
details of the object from the user.  They don't always have to be a
simple example.  What about a getter called getNextToLastItem().  Does
the object store the items as a list, an array, or a struct?  If you use
the getter, you don't have to know, nor will your code become dependant
upon the implantation of the CFC.

There are several theories on getters and setters, and not everyone
agrees on their usefulness.  I've found some of the more advanced levels
of Object Orientedness seem to lose their value, the smaller your
programming team is.  For instance, if you are responsible for writing
the CFC AND using it, you have to know its inner workings anyway so
abstraction might not be that big of a deal to you.  (Not to say it
still couldn't provide usefulness at some level).

Regardless, design patters (like getters and setters) do not exist
because your code will not work otherwise.  They exist to accommodate
and encourage good coding practices.  YMMV.

~Brad

-----Original Message-----
From: Will Tomlinson [mailto:[EMAIL PROTECTED] 
Sent: Monday, June 23, 2008 11:46 AM
To: CF-Talk
Subject: Why do I need getters/setters?

I'm just not understanding why I'd need a getter and a setter in my cfc.


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to 
date
Get the Free Trial
http://ad.doubleclick.net/clk;203748912;27390454;j

Archive: 
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:307975
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4

Reply via email to