You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@flex.apache.org by Alex Harui <ah...@adobe.com> on 2014/02/28 19:10:13 UTC
[FlexJS] Metadata (was Re: [FlexJS] SVG based TextButton and
example checked in)
Metadata probably deserves its own thread.
Fear not, there will be Metadata support in FlexJS. IIRC, there was a
long thread about Metadata a long time ago, but now might be a good time
to re-collect the various uses of Metadata so we can understand how we
want to implement it, especially on the JS side.
Falcon already compiles Metadata and adds selected metadata tags to the
class definition just like MXMLC does. You can set some options to
include some metadata tags and not others. You get the metadata by
calling describeType or describeTypeJSON
For FalconJX, my guess would be that we would add metadata to the
FLEXJS_CLASS_INFO structure we add to generated classes and have to
manually maintain for parallel classes. We'll have to create a
describeTypeJSON function mimics what the AS version returns. The key
limitation that will affect existing third-party libraries is that
describeType returns XML and folks used e4x to parse it, and code like
that will not cross-compile. Not sure if all of the major libraries used
describeTypeJSON or not. If not, we might have to do some monkey patching
to get them to work.
An interesting outcome of the FalconJX proposed implementation is that
metadata access will probably be much faster in JS than in AS since it is
accessed as a property and not via some reflection API. It makes you
wonder if we should change Falcon to also attach FLEXJS_CLASS_INFO
structures to classes so new AS code can get faster access to this sort of
metadata.
Then there is the question of what the compiler should do with Metadata,
if anything. I believe there are three kinds of metadata today:
1) IDE metadata like [Inspectable] that the IDE uses to do its job and
generally does not end affect compiler output or end up in the output.
2) Compiler directives like [Bindable] and [ExcludeClass] which affect
what the compiler (including the ASDoc compiler) generates. [Bindable]
also ends up in the output, IIRC.
3) Other metadata. They don't affect what the compiler outputs and are
used at runtime.
Are there any other kinds of metadata?
The metadata syntax appears to be: open-square-bracket tag
optional-open-parenthesis optional-name-value pairs,
optional-close-parenthesis close-square-bracket.
Does anybody have any desire to change that? Should we add an optional
name-value pair that determines if the metadata is kept in the output?
Looks like that's how it is done in Java annotations, and not getting the
compiler's list of kept metadata correct is a frequent issue for folks.
Should we provide some way to add other libraries that would affect
codegen for metadata? Currently the compiler behavior for [Binding] is
hard coded. No way to change what it generated and no way to add some
other metadata the changes some other codegen.
My main objection to metadata is that it is, for Flash/AIR, the slowest
possible convention for adding properties to a class. I'd rather populate
a set of properties like we do for FLEXJS_CLASS_INFO in FlexJS. It is
prone to typos: the compiler will not catch misspellings. But it's here
and not going away. But is it worth any cycles to try to make it better?
-Alex
On 2/28/14 6:59 AM, "Carlos Rovira" <ca...@codeoscopic.com> wrote:
>>This got cut off so I'm not sure what your thoughts were. I'm not a huge
>fan of MetaData but we will have it in FlexJS
>
>Alex, Metadata is one of the things we have in Flex and not available in
>pure JS. I'm a huge advocate of metadata, both for generating code at
>compilation time or for later processing at runtime. In Java Annotations
>are a huge step forward, and IMO in AS3/Flex Metadata is one of the
>features for people wanting to go Flex 4 or FlexJS. We can underestimate
>the importance of such feature for the future of FlexJS. As you're one of
>the main heads of the project, I'd like to convince you of the importance
>of taking Metadata seriously into account when planning whatever feature.
>Moreover, I'd like someday to be able to get a decent AOP functionality as
>we have in Java.
Re: [FlexJS] Metadata (was Re: [FlexJS] SVG based TextButton and
example checked in)
Posted by Carlos Rovira <ca...@codeoscopic.com>.
> 1) IDE metadata like [Inspectable] that the IDE uses to do its job and
> generally does not end affect compiler output or end up in the output.
>
IMO, this is the less valuable kind of metadata, since does not serves a
final output purpose, and implies support in IDEs.
> 2) Compiler directives like [Bindable] and [ExcludeClass] which affect
> what the compiler (including the ASDoc compiler) generates. [Bindable]
> also ends up in the output, IIRC.
>
This's needed. For example, [Bindable] must be the metadata with most % of
use by all flex developers in all kind of projects.
based on this list of available flex metadata
http://help.adobe.com/en_US/flex/using/WS2db454920e96a9e51e63e3d11c0bf680e1-7ffe.html
This is the list I use most of the time:
Bindable
DefaultProperty
Event
HostComponent
RemoteClass (other key point in Flex technology -> AMF support over JSON)
SkinPart
SknState
Style
Transient
Maybe this could represent the 50% of metadata use in some flex app
> 3) Other metadata. They don't affect what the compiler outputs and are
> used at runtime.
>
This's needed too as the before kind
My List here use to hold IOC frameworks, StateMachine, and validation. For
ejemple:
For IOC:
Inject
Dispatcher
EventHandler
Postconstruct
...and so on
Validation:
NotNull
Null
Size
Max
Pattern
...and more
StateMachine:
EnterState
ExitState
...
There's more for localization, resources,... for sure other people will use
other metadata...
Used to be maybe other 50% of the global metadata global use or event
more...
For this one, this is maybe could be done as add-on projects to FlexJS
(historically this was done outside FlexSDK)
>
> Are there any other kinds of metadata?
>
I think that's all.
>
> The metadata syntax appears to be: open-square-bracket tag
> optional-open-parenthesis optional-name-value pairs,
> optional-close-parenthesis close-square-bracket.
>
right
>
> Does anybody have any desire to change that? Should we add an optional
> name-value pair that determines if the metadata is kept in the output?
> Looks like that's how it is done in Java annotations, and not getting the
> compiler's list of kept metadata correct is a frequent issue for folks.
>
I think you refer here to the need to inform about the keeped metadata?
If you are talking about this, I think we should avoid the need to add that
config since, If you add a library that adds new metadata, normally you
want to get it without the need to inform the compiler manually.
>
> Should we provide some way to add other libraries that would affect
> codegen for metadata? Currently the compiler behavior for [Binding] is
> hard coded. No way to change what it generated and no way to add some
> other metadata the changes some other codegen.
>
That would be useful, but for me this is for a next iteration.
For example more important for me could be the use of constants in metadata
name-value pairs out-of-the-box
>
> My main objection to metadata is that it is, for Flash/AIR, the slowest
> possible convention for adding properties to a class. I'd rather populate
> a set of properties like we do for FLEXJS_CLASS_INFO in FlexJS. It is
> prone to typos: the compiler will not catch misspellings. But it's here
> and not going away. But is it worth any cycles to try to make it better?
>
I think all this problems could be addressed. For errors and typos, it
could be solved if in some way we add types (like java annotations), but
maybe this could means define the metadata in an external file like we do
with a class. I think this will be what people like me would prefer, but
right now I buy the classic AS3 metadata.
>
> -Alex
>
> On 2/28/14 6:59 AM, "Carlos Rovira" <ca...@codeoscopic.com> wrote:
>
> >>This got cut off so I'm not sure what your thoughts were. I'm not a huge
> >fan of MetaData but we will have it in FlexJS
> >
> >Alex, Metadata is one of the things we have in Flex and not available in
> >pure JS. I'm a huge advocate of metadata, both for generating code at
> >compilation time or for later processing at runtime. In Java Annotations
> >are a huge step forward, and IMO in AS3/Flex Metadata is one of the
> >features for people wanting to go Flex 4 or FlexJS. We can underestimate
> >the importance of such feature for the future of FlexJS. As you're one of
> >the main heads of the project, I'd like to convince you of the importance
> >of taking Metadata seriously into account when planning whatever feature.
> >Moreover, I'd like someday to be able to get a decent AOP functionality as
> >we have in Java.
>
>
--
Carlos Rovira
Director de TecnologĂa
M: +34 607 22 60 05
F: +34 912 94 80 80
http://www.codeoscopic.com
http://www.directwriter.es
http://www.avant2.es