When to use getters/setters with CFC's

Ask a Question related to Coldfusion - Advanced Techniques, Design and Development.

  1. #1

    Default When to use getters/setters with CFC's

    I'm a bit confused as to when it is good practice to use getter/setter methods
    in CFC's and when to use the THIS scope to make the properties publicly
    available. There are some articles around, but some are creating getter/setter
    methods for each property while others strongly discourage using getter/setter
    methods for single properties and even others are just creating all properties
    in the THIS scope so there is no need for getter/setter methods. Does anyone
    know of a comprehensive article that explains this very clearly (in relation to
    CFC's)

    droopcat Guest

  2. Similar Questions and Discussions

    1. Nesting functions in CFC's
      I'm trying to move the contents of my Application.cfm and OnRequestEnd.cfm to a new Application.cfc. Everything works, except for the UDF's. I need...
    2. Pathing with CFC's
      I'm reading Ben Forta's (EXCELLENT) book, but he (as well as every site I've Google'd so far) does not give information about the question I'm going...
    3. Calling Cfc's
      I am developing two applications on the same server that will have a lot of overlapping functionality. Hence, I would like to share cfcs between the...
    4. getters and setters
      I am new to CFCs and I think I am missing the point of getters and setters A lot of the text says that when writing a cfc we should write getter...
    5. [PHP-DEV] static property setters
      Andi, Zeev, Mind if I add #define ZEND_STATIC_PUBLIC_PROPERTY(class_ptr, name, value) \ { \ char *_name = (name);
  3. #2

    Default Re: When to use getters/setters with CFC's

    droopcat wrote:
    > I'm a bit confused as to when it is good practice to use getter/setter methods
    > in CFC's and when to use the THIS scope to make the properties publicly
    > available. There are some articles around, but some are creating getter/setter
    > methods for each property while others strongly discourage using getter/setter
    > methods for single properties and even others are just creating all properties
    > in the THIS scope so there is no need for getter/setter methods. Does anyone
    > know of a comprehensive article that explains this very clearly (in relation to
    > CFC's)
    >
    I'm sure you'll get multiple opinions on this, but here's my take. In
    general I don't use the THIS scope in my CFCs. The THIS scope makes
    everything publicly-available directly to the world outside the CFC. If
    you use the variables scope and getters/setters, then you have more
    control over things and can (if you need to) add validation, permission
    checking, and all sorts of other functionality to work with your getters
    and setters. That way the requests to get and set your CFC attributes
    can be more controlled.

    Matt

    --
    Matt Woodward
    Team Macromedia - ColdFusion
    mpwoodward *TMM* Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139