I understand that this is PAYG in terms of code size. My concern is that we’re paying in other ways for this composition pattern.
We’re reducing code size but increasing complexity (user needs to check for null before calling a method). Also, IDEs may have a hard time hinting for beads that may or may not exist. I agree that the performance issue can probably be mitigated with caching or something. I’m raising this issue so we can agree on a way to write components. Should users be expected to make calls with (strand.getBeadByType(Functionality) as Functionality).method() or tlc.method(). I’m pretty sure users will prefer the latter so I guess the compromise is to create TLCs that internally load beads. Thoughts? ________________________________ From: Alex Harui <[email protected]> Sent: Monday, May 6, 2019 9:02:18 AM To: [email protected] Subject: Re: Using @extrens ( RE: Example of access external JS using Apache Royale) IMO, it is PAYG. There is no cost until you use it, since getBeadByType is part of the IStrand implementation. In a true implementation, you would test for animateBead == null if you expect that it can be null, since that would be handling the "has not" case. If your concern is performance, as in, how slow is it to call getBeadByType()? That's a different and legitimate question. I'm mainly trying to point out that the "has" question is possible in a composition-oriented framework and is more flexible than requiring "is" (which results in increased code size as the TLC has to implement some interface. The performance hit would depend on how many places in the code need to ask "has" and how often. It might be/should be possible to optimize IStrand if we know that getBeadByType is being called often, with the usual trade-offs on code size. All we need is some folks to try it and do some measurements. My 2 cents, -Alex On 5/5/19, 5:03 AM, "Yishay Weiss" <[email protected]> wrote: >if you can get yourself away from trying to access features on concrete instances (…) >var animateBead:IAnimateBead = indicator_content.getBeadByType(IAnimateBead); >animateBead.animate(); Is this PAYG? getBeadByType iterates through an array. Also, animateBead may turn out to be null which adds a level of uncertainty as to whether or not this will run.
