Dynamic Flash

Confessions of a serial code abuser
  • rss
  • Home
  • MTASC
  • Archives
  • About me
  • Goodies
    • Base64 encoder/decoder class
  • My Bookshelf
  • My Talks

MTASC 1.12 OS X and Linux

Tuesday, 31 January 2006

What’s new in 1.12?

  • prevented -keep with -header
  • allowed dynamic static classes
  • improved Flash8 shapes support
  • allowed access to private variables inside local defined functions
  • faster SWF parsing

Download MTASC

Comments
Comments Off
Categories
General
Comments rss Comments rss
Trackback Trackback

Sorry about the blog barf

Sunday, 29 January 2006

It seems that in the process of upgrading Wordpress that I have confused MXNA into aggregating all of my posts as though they were new. I get really frustrated when this happens with other blogs, so I just wanted to apologise.

Comments
4 Comments »
Categories
General
Comments rss Comments rss
Trackback Trackback

Efficiently populating a DataGrid control

At Featurecreep HQ we’re currently working on the next iteration of our flagship content management system. Whilst thrashing out the UI for a particular part of the administrative interface, we came across a requirement to display a lot – and I mean a lot – of information in a DataGrid control. Having had previous bad experience with the Tree control, I wanted to do a proof of concept before commiting to the idea.

My first attempt was just as you’d expect: create a loop that, on each iteraction, added a row to the DataGrid using the addItem() method…

for (var i:Number = 0; i < 100000; i++) {
    dg.addItem({test:"Test"});
}

This worked out to be painfully slow in my PowerMac G5 at work, taking over 45 seconds to populate the DataGrid. Ouch! Not only is this an unacceptable amount of time to force the user to wait, it also meant that the 15 second script timeout alert popped up at least 3 times. Faced with such an uphill struggle, it was at this point that I started to think about adding the rows in batches over a number of seconds using intervals. Fortunately I don’t give up that easily, and set about finding some way to optimise the code.

I wondered if it might be quicker if I built the array of items first and then added them to the DataGrid using the dataProvider property. I knew that the Array class has some mix-in methods applied when you include any V2 component in your SWF, and I figured that these must be optimed for speed. The method I was particularly interested in was the addItem() method so I decided to give it a go…

var dp:Array = new Array();
for (var i:Number = 0; i < 100000; i++) {
  dp.addItem({test:"Test"});
}
dg.dataProvider = dp;

The total time for populating the DataGrid this time was around 19 seconds; a 3x increase in speed compared to adding each item directly to the DataGrid. Not bad, but still under the default 15 second script timeout limit and so still not acceptable.

On further testing it seemed that it was taking only a fraction of a second to assign my data provider to the DataGrid. The rest of the execution time was taken up by populating the data provider in the loop. Thinking that the mix-in methods maybe weren’t so optimised after all, I tried using Array.push() to see if that was any quicker…

var dp:Array = new Array();
for (var i:Number = 0; i < 100000; i++) {
  dp.push({test:"Test"});
}
dg.dataProvider = dp;

Result! Total execution time for the above code was just over 4 seconds. That’s almost 5x the speed of using the mix-in methods, and 15x the speed of using DataGrid.addItem(). I’m not sure what extra functionality the mix=in methods perform, but for our purposes they certainly aren’t worth a 5x increase in execution time.

So, the moral of this little tale is not to use the data provider mix-in methods unless speed of execution isn’t a requirement or you absolutely must; this probably applies to all of the list-based controls in the V2 UI component set.

My next task is to see if I can find a more efficient way of sorting the data when you click on a column header. Wish me luck!

PS. Please excuse the small code text and lack of syntax highlighting. I’ve just updated to Wordpress 2.0 but my usual syntax highlighting plugin has not yet been updated.

Comments
5 Comments »
Categories
General
Tags
component, Flash, performance
Comments rss Comments rss
Trackback Trackback

How not to develop ANY software, let alone Open Source

Tuesday, 17 January 2006

I’ve just finished reading an article entitled Open Source Development and How-To Protect Your Investment in Time. Before I started I figured it was going to be an article on the more commercial friendly Open Source licenses. Boy, was I in for a shock.

Instead of espousing the virtues of choosing an appropriate OS license to cover your code, the developer in question suggests that you…

…spend as much time as possible working on each “product” … to make sure the code was as complex as possible and that the code covered as many “features” as possible so that nobody would ever want to spend any amount of time working on the code

This ‘experienced’ developer with 30 years of software development under his seems to be advocating obfuscation through complexity for projects released under an Open Source license. He’s afraid that someone will pick up his code and actually improve it, so he’s purposefully making his code complex to put off would-be contributors. Nice!

To attempt to back up his argument he uses one of the most prolific Open Source projects, Linux. He goes on to say…

This is the goal I think the Linux developers have used and very successfully. Oh sure, anyone can obtain Linux Source Code and look at it but I have no doubt the Linux Source Code is pretty complex either in terms of the amount of code or the depth of the development required to do serious work with it.

I’ll go out on a limb here and agree that the Linux code probably is very complex. However, it’s not complex because the development team wants to stop others from developing the code; it’s complex because an operating system is a very complex thing to code.

Hypocrisy, it seems, is not beneath him either. He’s taken on Ray Camden’s Open Source BlogCFC and allegedly improved it, releasing it under the name Rabid_BlogCFC. Obviously Ray was kind enough to NOT make his code so complex as to put other developers off. For what it’s worth, I wouldn’t go near this guy’s product which is why I’ve not linked directly to it. If you’re after this sort of thing, go download Ray Camden’s version instead.

I have no idea who wrote this article, but in my opinion they need to take a serious look at their attitude to software development. I certainly wouldn’t want to work with this person on any project of any size, and I’d be surprised in anyone else did either. This is the kind of petty-mindedness that leads to developers hoarding their code and not letting anyone else work on it because it is ‘theirs’, and those people make me angry.

Remember, advice is not good advice if it’s bullshit.

Comments
10 Comments »
Categories
General, Open Source
Comments rss Comments rss
Trackback Trackback

About Dynamic Flash

Steve Webster is a Senior Web Developer for Yahoo! in London, UK.

He is more than a little concerned that he defines himself in terms of his career, and that he talks about himself in the third person.

Find out more

del.icio.us-ed

  • samuel's squawk at master - GitHub
  • Pixelwave - A native 2D iPhone framework, based on the Flash API
  • Pixelwave - A native 2D iPhone framework, based on the Flash API
  • mnot’s Weblog: Are Resource Packages a Good Idea?
  • Download details: IE App Compat VHD
  • ZSync
  • jQuery source viewer
  • Penetration testing tools - Stack Overflow
  • Logrep
  • DOM Window (jquery.DOMWindow.js)

Recent Posts

  • Moving on
  • iPhone / iPod Touch Development Resources
  • Upgrading your app to AIR 1.5
  • Motivate yourself by doing it in public
  • The trouble with Flash and REST
rss Comments rss valid xhtml 1.1 design by jide powered by Wordpress get firefox