Re: [flexcoders] Dictionary bug

2008-05-28 Thread Troy Gilbert
 XML read/write is much slower than access of other class instances.  If
 you're going to do lots of reading and writing, I would consider converting
 the XML data to object data.

As an aside, is there any reason why Adobe hasn't provided API for
serializing to/from XML and typed-objects? This certainly exists in a
lot of other major platforms (ahem, .NET), and it'd be incredibly
useful since we're dealing with web services all the time, etc...

Troy.


Re: [flexcoders] Dictionary bug

2008-05-28 Thread Troy Gilbert
 Dammit, why didn't I think of strings to one-entry dictionaries? Genius!
 Alex, that's why you're the judge, and I'm the law.. talking.. guy :)
 Collecting the empty dictionaries would be a pretty simple job to do on a
 timer using something similar to your background thread code too.

I think Grant Skinner may have create a general purpose weak reference
class that does just this. Go check out his blog...

Troy.


RE: [flexcoders] Dictionary bug

2008-05-28 Thread Alex Harui
We have mx.rpc.SimpleXMLDecoder, and some undocumented decoders as well.

 



From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On
Behalf Of Troy Gilbert
Sent: Wednesday, May 28, 2008 10:22 AM
To: flexcoders@yahoogroups.com
Subject: Re: [flexcoders] Dictionary bug

 

 XML read/write is much slower than access of other class instances. If
 you're going to do lots of reading and writing, I would consider
converting
 the XML data to object data.

As an aside, is there any reason why Adobe hasn't provided API for
serializing to/from XML and typed-objects? This certainly exists in a
lot of other major platforms (ahem, .NET), and it'd be incredibly
useful since we're dealing with web services all the time, etc...

Troy.

 



Re: [flexcoders] Dictionary bug

2008-05-28 Thread Troy Gilbert
 We have mx.rpc.SimpleXMLDecoder, and some undocumented decoders as well.

But those just convert to/from generic objects, right? I'm talking
about typed objects (for best performance). All the examples I see
with SimpleXMLDecoder go to/from generic objects.

I'd actually be cool with code generators, even (that's how .NET
addresses it). I think Flex is really needing these types of tools
(and was hoping Flex 3 would deliver them). I should be able to write
a single schema that then generates classes with XML serialization
automatically.

In fact, I *should* be able to write a single schema and then have a
code generator that creates the AS3 model classes, server-side classes
(Java, PHP, Ruby, etc.) *and* SQL queries to create the table. Kinda
like RoR's migrations (but with the necessity of client-side classes
as well). Basic DRY stuff.

I wish my job would afford me the time to write these tools myself! ;-)

Troy.


Re: [flexcoders] Dictionary bug

2008-05-28 Thread Josh McDonald
Don't we all dude :)

On Thu, May 29, 2008 at 7:29 AM, Troy Gilbert [EMAIL PROTECTED]
wrote:


 I wish my job would afford me the time to write these tools myself! ;-)

 Troy.
  




-- 
Therefore, send not to know For whom the bell tolls. It tolls for thee.

:: Josh 'G-Funk' McDonald
:: 0437 221 380 :: [EMAIL PROTECTED]


RE: [flexcoders] Dictionary bug

2008-05-28 Thread Alex Harui
Well, it doesn't look it would be hard to customize to generate other
classes, but thinking about it more, your own custom converter will
always be faster than one that spins through lists of attributes and
properties.

 



From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On
Behalf Of Josh McDonald
Sent: Wednesday, May 28, 2008 2:57 PM
To: flexcoders@yahoogroups.com
Subject: Re: [flexcoders] Dictionary bug

 

Don't we all dude :)

On Thu, May 29, 2008 at 7:29 AM, Troy Gilbert [EMAIL PROTECTED]
mailto:[EMAIL PROTECTED]  wrote:


I wish my job would afford me the time to write these tools myself! ;-)

Troy.




-- 
Therefore, send not to know For whom the bell tolls. It tolls for
thee.

:: Josh 'G-Funk' McDonald
:: 0437 221 380 :: [EMAIL PROTECTED] mailto:[EMAIL PROTECTED]  

 



Re: [flexcoders] Dictionary bug

2008-05-28 Thread Josh McDonald
I've actually written a generic populate() that populates a real class from
an ObjectProxy returned from WebService. It's not that hard, and that's
including some custom parsing stuff for ISO dates, and booleans that aren't
booleans in the XSD etc. I can't post it because it's part of a proprietary
codebase, but I have started work on something similar but broader and more
robust in my spare time where there's no deadlines ;-) That'll be open
source!

-J

On Thu, May 29, 2008 at 11:28 AM, Alex Harui [EMAIL PROTECTED] wrote:

Well, it doesn't look it would be hard to customize to generate other
 classes, but thinking about it more, your own custom converter will always
 be faster than one that spins through lists of attributes and properties.


  --

 *From:* flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] *On
 Behalf Of *Josh McDonald
 *Sent:* Wednesday, May 28, 2008 2:57 PM
 *To:* flexcoders@yahoogroups.com
 *Subject:* Re: [flexcoders] Dictionary bug



 Don't we all dude :)

 On Thu, May 29, 2008 at 7:29 AM, Troy Gilbert [EMAIL PROTECTED]
 wrote:


 I wish my job would afford me the time to write these tools myself! ;-)

 Troy.




 --
 Therefore, send not to know For whom the bell tolls. It tolls for thee.

 :: Josh 'G-Funk' McDonald
 :: 0437 221 380 :: [EMAIL PROTECTED]

  




-- 
Therefore, send not to know For whom the bell tolls. It tolls for thee.

:: Josh 'G-Funk' McDonald
:: 0437 221 380 :: [EMAIL PROTECTED]


Re: [flexcoders] Dictionary bug

2008-05-27 Thread Josh McDonald
Why do Strings make bad keys in a Dictionary? Is it just because you get no
benefits over an Object but it's slower?

And If I wanted a map of String (or similar) to a weak reference of an
Object, what's the best way to achieve this? Is the only way to put the
Object as the key in a weakReference Dictionary, and the key Strings as
values in the Dictionary? This would make retrieval pretty slow if the
collection gets sizeable, as you'd have to loop through the Dictionary keys
looking for the value that's your actual key.

-J

On Wed, May 28, 2008 at 2:02 AM, Christophe Jolif [EMAIL PROTECTED] wrote:

   Alex,


 Alex Harui wrote:
  Dictionary keys should be objects.

 That's why I advised him to use Array not Dictionary...

 I must admit I don't know exactly what Daniel wants to do but his method
 name
 (getItem) reminds me a lot of similar things in Adobe Flex SDK such as
 ListBase.itemToItemRenderer method that are exactly doing what I propose.
 That's why I suggested him that workaround. But maybe I miss something...

 --
 Christophe
 http://blogs.ilog.com/elixir/author/cjolif

  




-- 
Therefore, send not to know For whom the bell tolls. It tolls for thee.

:: Josh 'G-Funk' McDonald
:: 0437 221 380 :: [EMAIL PROTECTED]


RE: [flexcoders] Dictionary bug

2008-05-27 Thread Alex Harui
Strings are interned so their reference counting can be tricky and
defeat the weakreference capabilities of Dictionary.  I'd just use an
Object if my keys were strings.

 

There is no efficient mapping of strings to weak object references.  You
can map stirngs to a Dictionary of Dictionaries where each
sub-dictionary has one key, but you may still need to collect the empty
sub-dictionaries at some point.

 

 

 



From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On
Behalf Of Josh McDonald
Sent: Tuesday, May 27, 2008 3:52 PM
To: flexcoders@yahoogroups.com
Subject: Re: [flexcoders] Dictionary bug

 

Why do Strings make bad keys in a Dictionary? Is it just because you get
no benefits over an Object but it's slower?

And If I wanted a map of String (or similar) to a weak reference of an
Object, what's the best way to achieve this? Is the only way to put the
Object as the key in a weakReference Dictionary, and the key Strings as
values in the Dictionary? This would make retrieval pretty slow if the
collection gets sizeable, as you'd have to loop through the Dictionary
keys looking for the value that's your actual key.

-J

On Wed, May 28, 2008 at 2:02 AM, Christophe Jolif [EMAIL PROTECTED]
mailto:[EMAIL PROTECTED]  wrote:

Alex,



Alex Harui wrote:
 Dictionary keys should be objects.

That's why I advised him to use Array not Dictionary...

I must admit I don't know exactly what Daniel wants to do but his method
name 
(getItem) reminds me a lot of similar things in Adobe Flex SDK such as 
ListBase.itemToItemRenderer method that are exactly doing what I
propose. 
That's why I suggested him that workaround. But maybe I miss
something...

-- 

Christophe
http://blogs.ilog.com/elixir/author/cjolif
http://blogs.ilog.com/elixir/author/cjolif 




-- 
Therefore, send not to know For whom the bell tolls. It tolls for
thee.

:: Josh 'G-Funk' McDonald
:: 0437 221 380 :: [EMAIL PROTECTED] mailto:[EMAIL PROTECTED]  

 



Re: [flexcoders] Dictionary bug

2008-05-27 Thread Josh McDonald
Dammit, why didn't I think of strings to one-entry dictionaries? Genius!
Alex, that's why you're the judge, and I'm the law.. talking.. guy :)
Collecting the empty dictionaries would be a pretty simple job to do on a
timer using something similar to your background thread code too.

-J

On Wed, May 28, 2008 at 9:01 AM, Alex Harui [EMAIL PROTECTED] wrote:

Strings are interned so their reference counting can be tricky and
 defeat the weakreference capabilities of Dictionary.  I'd just use an Object
 if my keys were strings.



 There is no efficient mapping of strings to weak object references.  You
 can map stirngs to a Dictionary of Dictionaries where each sub-dictionary
 has one key, but you may still need to collect the empty sub-dictionaries at
 some point.






  --

 *From:* flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] *On
 Behalf Of *Josh McDonald
 *Sent:* Tuesday, May 27, 2008 3:52 PM
 *To:* flexcoders@yahoogroups.com
 *Subject:* Re: [flexcoders] Dictionary bug



 Why do Strings make bad keys in a Dictionary? Is it just because you get no
 benefits over an Object but it's slower?

 And If I wanted a map of String (or similar) to a weak reference of an
 Object, what's the best way to achieve this? Is the only way to put the
 Object as the key in a weakReference Dictionary, and the key Strings as
 values in the Dictionary? This would make retrieval pretty slow if the
 collection gets sizeable, as you'd have to loop through the Dictionary keys
 looking for the value that's your actual key.

 -J

 On Wed, May 28, 2008 at 2:02 AM, Christophe Jolif [EMAIL PROTECTED] wrote:

 Alex,



 Alex Harui wrote:
  Dictionary keys should be objects.

 That's why I advised him to use Array not Dictionary...

 I must admit I don't know exactly what Daniel wants to do but his method
 name
 (getItem) reminds me a lot of similar things in Adobe Flex SDK such as
 ListBase.itemToItemRenderer method that are exactly doing what I propose.
 That's why I suggested him that workaround. But maybe I miss something...

 --

 Christophe
 http://blogs.ilog.com/elixir/author/cjolif




 --
 Therefore, send not to know For whom the bell tolls. It tolls for thee.

 :: Josh 'G-Funk' McDonald
 :: 0437 221 380 :: [EMAIL PROTECTED]

  




-- 
Therefore, send not to know For whom the bell tolls. It tolls for thee.

:: Josh 'G-Funk' McDonald
:: 0437 221 380 :: [EMAIL PROTECTED]


Re: [flexcoders] Dictionary bug

2008-05-27 Thread Daniel Freiman
The short version is that I have a Directed Acyclic Graph class.  The
example code was retrieving a node from the graph.  I don't need weakKeys
because the node set is controlled.  Anything in the Dictionary that would
be eligible for collection would have necessarily already been removed from
the Dictionary.  So in the case of XML I'm now assigning a UID to an
attribute of the XML and using the value of that attribute as the key.  It
didn't give me the performance increase I was hoping for, but it is better.
If an Object were faster than a Dictionary I would switch over, but if
they're equivalent I'll keep the Dictionary to key the Class more
generalized.

- Daniel Freiman

On Tue, May 27, 2008 at 12:02 PM, Christophe Jolif [EMAIL PROTECTED] wrote:

   Alex,


 Alex Harui wrote:
  Dictionary keys should be objects.

 That's why I advised him to use Array not Dictionary...

 I must admit I don't know exactly what Daniel wants to do but his method
 name
 (getItem) reminds me a lot of similar things in Adobe Flex SDK such as
 ListBase.itemToItemRenderer method that are exactly doing what I propose.
 That's why I suggested him that workaround. But maybe I miss something...

 --
 Christophe
 http://blogs.ilog.com/elixir/author/cjolif

  



Re: [flexcoders] Dictionary bug

2008-05-27 Thread Josh McDonald
As object and dictionary use the same syntax, it shouldn't be too hard to do
some quick testing to determine which is faster when using strings as keys.

-J

On Wed, May 28, 2008 at 2:28 PM, Daniel Freiman [EMAIL PROTECTED] wrote:

   The short version is that I have a Directed Acyclic Graph class.  The
 example code was retrieving a node from the graph.  I don't need weakKeys
 because the node set is controlled.  Anything in the Dictionary that would
 be eligible for collection would have necessarily already been removed from
 the Dictionary.  So in the case of XML I'm now assigning a UID to an
 attribute of the XML and using the value of that attribute as the key.  It
 didn't give me the performance increase I was hoping for, but it is better.
 If an Object were faster than a Dictionary I would switch over, but if
 they're equivalent I'll keep the Dictionary to key the Class more
 generalized.

 - Daniel Freiman


 On Tue, May 27, 2008 at 12:02 PM, Christophe Jolif [EMAIL PROTECTED] wrote:

   Alex,


 Alex Harui wrote:
  Dictionary keys should be objects.

 That's why I advised him to use Array not Dictionary...

 I must admit I don't know exactly what Daniel wants to do but his method
 name
 (getItem) reminds me a lot of similar things in Adobe Flex SDK such as
 ListBase.itemToItemRenderer method that are exactly doing what I propose.
 That's why I suggested him that workaround. But maybe I miss something...

 --
 Christophe
 http://blogs.ilog.com/elixir/author/cjolif


  




-- 
Therefore, send not to know For whom the bell tolls. It tolls for thee.

:: Josh 'G-Funk' McDonald
:: 0437 221 380 :: [EMAIL PROTECTED]


RE: [flexcoders] Dictionary bug

2008-05-27 Thread Alex Harui
XML read/write is much slower than access of other class instances.  If
you're going to do lots of reading and writing, I would consider
converting the XML data to object data.

 



From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On
Behalf Of Josh McDonald
Sent: Tuesday, May 27, 2008 9:42 PM
To: flexcoders@yahoogroups.com
Subject: Re: [flexcoders] Dictionary bug

 

As object and dictionary use the same syntax, it shouldn't be too hard
to do some quick testing to determine which is faster when using strings
as keys.

-J

On Wed, May 28, 2008 at 2:28 PM, Daniel Freiman [EMAIL PROTECTED]
mailto:[EMAIL PROTECTED]  wrote:

The short version is that I have a Directed Acyclic Graph class.  The
example code was retrieving a node from the graph.  I don't need
weakKeys because the node set is controlled.  Anything in the Dictionary
that would be eligible for collection would have necessarily already
been removed from the Dictionary.  So in the case of XML I'm now
assigning a UID to an attribute of the XML and using the value of that
attribute as the key.  It didn't give me the performance increase I was
hoping for, but it is better.  If an Object were faster than a
Dictionary I would switch over, but if they're equivalent I'll keep the
Dictionary to key the Class more generalized.

- Daniel Freiman

 

On Tue, May 27, 2008 at 12:02 PM, Christophe Jolif [EMAIL PROTECTED]
mailto:[EMAIL PROTECTED]  wrote:

Alex,



Alex Harui wrote:
 Dictionary keys should be objects.

That's why I advised him to use Array not Dictionary...

I must admit I don't know exactly what Daniel wants to do but his method
name 
(getItem) reminds me a lot of similar things in Adobe Flex SDK such as 
ListBase.itemToItemRenderer method that are exactly doing what I
propose. 
That's why I suggested him that workaround. But maybe I miss
something...

-- 

Christophe
http://blogs.ilog.com/elixir/author/cjolif
http://blogs.ilog.com/elixir/author/cjolif 

 




-- 
Therefore, send not to know For whom the bell tolls. It tolls for
thee.

:: Josh 'G-Funk' McDonald
:: 0437 221 380 :: [EMAIL PROTECTED] mailto:[EMAIL PROTECTED]