> Well, that's not PAYG (yes, I'm being picky). I disagree. For string it certainly is PAYG. There’s no extra cost. (and considering the three bytes of ‘=“”’ in the source code is getting petty IMO) Adding an extra TextModelWithEmptyStringDefaults is totally unnecessary.
> Again, what > percentage of the time in production will a label's text property not be > set to something other than “"? More than you’d think. We ran into this because we were using ImageAndTextButton without text. But it’s quite common to have components which get text or not at runtime. > but wouldn't be ok for an Array or Object. The instnatiation and > assignment of non-scalar initial values happens on every instantiation. That’s valid, and we should not instantiate these unnecessarily. > On Feb 17, 2017, at 12:02 AM, Alex Harui <aha...@adobe.com> wrote: > > > > On 2/16/17, 12:00 PM, "Harbs" <harbs.li...@gmail.com> wrote: > >> I recently went this course in TextModel. By default, the text property >> was undefined which propagated to the view when it was never set. I >> changed it to 'private var _text:String = “”;' to set the default to an >> empty string. > > Well, that's not PAYG (yes, I'm being picky). It is probably ok for > String, but wouldn't be ok for an Array or Object. The instnatiation and > assignment of non-scalar initial values happens on every instantiation. > > It is totally fine, however, to have a TextModelWithEmptyStringDefaults. > And have Express use it and Harbs could use it in his app. Again, what > percentage of the time in production will a label's text property not be > set to something other than ""? > > It is also totally fine to create a version of Basic with lots of error > checking and other fault tolerance. There is no one right answer. > > IMO, in Justin's example, he is creating his own uninitialized variable > and assigning it via binding. So default values in a TextModel won't > matter. > > My 2 cents, > -Alex >