Ramblings

December 7, 2009

AS3 Iteration with valueobjects in collections

Filed under: as3, tip — michaelangela @ 7:28 am

Using valueobjects might be overkill for some really simple things that only require a couple of values where you can just throw an object together quickly. Unless speed is an issue where they strongly typed values have a lower overhead than plain objects (as I understand it). Unless you’re in a big app and you just made a change to some code and suddenly all your other uses of that object break and you’re not aware of it and null exceptions start flying and…. I digress. Having them in a set collection is great, too, for similar same reasons, plus the added ability to create convenience functions specific to that particular data set. But this post says it all very well with code to boot.

AS3: Collection, ValueObject, & Iterator

A while ago I blogged about converting Collection and Iterator classes to AS3 since storing data in ValueObjects has become a regular practice in my coding. I really like how VOs are strongly typed and how you use a Collection to hold all the data together nicely. I am working on a project right now that allowed me to see even better uses for these things so I added a couple of simple (but helpful) methods to my Collection class (most notably the ability to add an item at a specified index as well as output the data currently existing in the collection easily) and created a base ValueObject class that allows you to easily output the data in that VO.

Important to also note is the package move. I’ve moved everything into a com.reintroducing.data package as I believe this fits better with what these classes are actually doing. There is also interfaces for ValueObject and Collection as well.

Just so you don’t have to flip back and forth between posts, I’ll post the classes and data here with a little explanation of each.

Advertisements

Leave a Comment »

No comments yet.

RSS feed for comments on this post. TrackBack URI

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Create a free website or blog at WordPress.com.

%d bloggers like this: