project package structure

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

project package structure

Serkan Taş
Hi,

My package naming convention of flex mxl files has java-like structure.

is it good for Royale ?


Reply | Threaded
Open this post in threaded view
|

Re: project package structure

Alex Harui-2
Whatever package naming you use in Flex should work in Royale.  Depending
on what level of optimization you ask for in Royale, packages can be
collapsed in the final output.  That's usually ok, but I'll bet we still
have a bug or two around that.

Not required reading below...

Under the hood, an ActionScript package is just a string.  When you have
code in ActionScript like:

  new org.apache.royale.Foo();

The compiler simply generates:

  FindAClassCalled "org.apache.flex.royale::Foo"
  NewInstance

It doesn't matter too much how long the package name is or how many dots
it has in it.  However, in JavaScript, the output code is pretty much the
same as the source:

  new org.apache.royale.Foo();

And that means the JavaScript runtime has to do something like:

  Register a = window;
  a = a["org"];
  a = a["apache"];
  a = a["royale"];
  a = a["Foo"];
  NewInstance

As you can see, the number of dots in the package name change the number
of lookups before instantiation.  So, the JavaScript optimizer collapses
package names.  It generates additional code like:

  window["AJ"] = org.apache.royale.Foo();

And converts the output to:

  new AJ();

Which is fewer lookups and faster and smaller if you have several places
in the JS file where the string "org.apache.royale.Foo" can be replaced by
"AJ".  But our Reflection and DataBinding libraries still have to work
from the original strings so I wouldn't be surprised if there is a bug in
there.

HTH,
-Alex

On 2/15/18, 12:58 PM, "Serkan Taş" <[hidden email]> wrote:

>Hi,
>
>My package naming convention of flex mxl files has java-like structure.
>
>is it good for Royale ?
>
>