These are the types of discussions that show the biggest weakness in CFML, the IDE. The answer is simple in most languages, use direct access until you need to wrap functionality around it. Most of the time this is a really simple refactor in an IDE. Even without refactor capabilities it's a pretty easy search/replace so I still go with that mentality.
Adam On Mon, Feb 15, 2010 at 9:44 AM, John Whish <[email protected]>wrote: > Hi, > > Just wondering what people consider to be best practice when writing > CFCs in terms of getting instance data internally. > > For example if I have the following: > > <cfcomponent> > <cffunction name="init"> > <cfargument name="foo" required="false" default="1234"> > <cfset instance.foo = "arguments.foo> > </cffunction> > > <cffunction name="timesTen"> > <cfreturn instance.foo * 10> > </cffunction> > </cfcomponent> > > Would you create and use a private getter and setter for mutating > "foo"? > > The way I see it is that using getters and setters internally means > that you can add extra functionality such as type checking etc, the > down side is extra code. > > Equally, if you have a public getter for "foo", should you then use > the getFoo() method in your instance code? Again the downside to this > is that you might have a getFoo() method, but not a getBar() method, > so you'd end up with inconsistent code. > > Not a ground breaking question, just curious to know what people > think! > > Thanks, > > - John > > -- > You received this message because you are subscribed to the Google Groups > "CFCDev" group. > To post to this group, send email to [email protected]. > To unsubscribe from this group, send email to > [email protected]<cfcdev%[email protected]> > . > For more options, visit this group at > http://groups.google.com/group/cfcdev?hl=en. > > -- You received this message because you are subscribed to the Google Groups "CFCDev" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/cfcdev?hl=en.
