Wednesday, February 09, 2011

My thoughts on AS3 Signals

Here’s my evaluation of Signals, and I’ll preface this by conceding that I haven’t actually tried them in a project to fully appreciate the amount of code savings.

1. I like the simplicity of the API. It’s different than the standard but at least it’s clear (probably more so than the standard). I like the addOnce feature a lot but it’s also pretty easy to explicitly remove my event listeners. I just copy the foo.addEventListener line and paste it where it needs to be removed, and erase the ‘add’ part and rename it to ‘remove’. That’s not a lot of typing. Admittedly though one can forget to do it at all, and it does add more code to your project overall. Big deal? Doesn’t seem like it.

2. I don’t see a huge code writing savings in the context that most coders use an IDE that helps them generate the extra boilerplate code. I’m either going to have my IDE create an Event subclass or I’m going to copy and paste an old one and tweak a couple parts of it by hand. That seems to me like just as much of a time saver as the brevity that Signals offers.

3. It’s really fast.

So, in summary, I see a lot of trivial benefits that don’t really persuade me to change a current project started with regular events or to introduce something that might seem esoteric to a future developer that needs to take over my code. #3 though seems to be the most unadvertised feature that is also the strongest argument. 4-13x faster is a pretty damn strong argument. Still – it depends on your project right? If your project won’t appreciate the speed benefits then maybe it’s better to stick with the conventional approach.

So, for me I think I’ll definitely reserve the use of Signals for a project with a more intense level of event dispatching.

I'm interested in your comments!

0 Comments:

Post a Comment

<< Home