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].
For more options, visit this group at 
http://groups.google.com/group/cfcdev?hl=en.

Reply via email to