<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Replacing Events with AS3Signals</title>
	<atom:link href="http://www.pleribus.com/index.php/2010/02/replacing-events-with-as3signals/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.pleribus.com/index.php/2010/02/replacing-events-with-as3signals/</link>
	<description>Clint Hannaford is a Senior Developer at Boffswana, working on Flash, Unity and iPhone projects.</description>
	<lastBuildDate>Mon, 27 Jun 2011 23:01:00 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: admin</title>
		<link>http://www.pleribus.com/index.php/2010/02/replacing-events-with-as3signals/comment-page-1/#comment-1958</link>
		<dc:creator>admin</dc:creator>
		<pubDate>Mon, 27 Jun 2011 23:01:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.pleribus.com/new_folio/?p=125#comment-1958</guid>
		<description>Apologies Amy, I completely missed your comment arriving in my inbox.  Just approved it.</description>
		<content:encoded><![CDATA[<p>Apologies Amy, I completely missed your comment arriving in my inbox.  Just approved it.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Amy</title>
		<link>http://www.pleribus.com/index.php/2010/02/replacing-events-with-as3signals/comment-page-1/#comment-1825</link>
		<dc:creator>Amy</dc:creator>
		<pubDate>Wed, 01 Jun 2011 01:09:36 +0000</pubDate>
		<guid isPermaLink="false">http://www.pleribus.com/new_folio/?p=125#comment-1825</guid>
		<description>I debated long and hard with myself about whether to come back to this discussion. As soon as someone (even partially) declares &quot;the debate is over and I won!&quot; I find it hard to believe that he has a sincere interest in my point of view. However, there are others following this, so I thought I&#039;d try one more time.

My husband, @SteveHoward999, says I often assume what is obvious to me is obvious to everyone, so let me go back and spell out in so many words what I believed at the outset should have been obvious, just in case it wasn&#039;t.

Clint, in his original post, says: &quot;others like myself, like to strongly type events with value objects wherever I can (resulting in many custom event classes per project).&quot; I presumed, rightly or wrongly, that this means that he found value in these strongly typed Events--specifically, in their Value Objects.  This seams to me to be a reasonable reading of the sentence.

From there I said that this strong typing is lost when you use Signals. Again, it is very abundantly obvious to me, and several people have confirmed, that Signals CANNOT check that the arguments on listening functions are of the correct type, and certainly not at compile time.  This is simply due to the way that As3 handles function references.

By contrast, you CAN&#039;T use dispatchEvent() to dispatch, say, a DisplayObject. So, at the very least, you know that you&#039;re getting an Event.  I suppose that some developers have trouble constantly dispatching or listening for the wrong Event Class but, in practice, I have never encountered this problem--and I have seen a lot of truly atrocious code.

The simple signatures for both dispatching and receiving events make _that_ part of the process pretty idiot proof.  And the compiler will alert you if you try to add an event listener that doesn&#039;t have at least one argument--something that you&#039;ll only get warning of at runtime with Signals.

Several people have talked about the type _property_ of an Event Object as somehow being involved in its type safety. This property is, in fact, a strongly typed Object (a String), but it doesn&#039;t matter whether you are using a strongly typed event, a regular Flash Event, or a DynamicEvent with a data property, this property always has exactly the same type safety. You can help make sure the same String is used throughout the application by using Constants, but whether those constants are used as part of the Event Class definition or not (or whether you don&#039;t even use constants) has zero bearing on the type safety or lack therof of the property.

So, it was very clear to me that this was _not_ what I was saying about the type safety you throw away by not using Events.  I was actually pretty surprised to be asked to defend a position I didn&#039;t take on this. 

I will say this: I think that the &quot;type&quot; property has a very clear semantic meaning, which is &quot;this is the specific way I want this (Class of) Event dealt with.&quot; The Flash Player has traditionally dealt with this by routing all Events with the same type property to the same handler, without regard for the actual Class of the event.  However, the way that Robotlegs handles this, by looking at both &quot;type&quot; and type, proves that the semantics of the default Event object are quite workable. If the FP implementation is a bit flawed, it still works extremely well.

Now let&#039;s look at the suggestion of using Signals to send an Event directly to a function. The Signal itself coopts and repeats the meaning of the Event&#039;s type property, and this property (the only mandatory Event property) could well become meaningless.  While this might have value in retrofitting Event-based code to use Signals, in new code this has a bad smell IMO.

I&#039;m going to move on to talking about my philosophy toward loose coupling, which is to use the absolutely least prescriptive Class Type needed to accomplish the job. If I have, say, a LoginView that has a SimpleButton that dispatches a bubbling LoginEvent, I can listen for that event on a LoginView instance without knowing anything about it other than it is a DisplayObject. If I needed to take it that far, I could type it as IEventDispatcher.

However, to listen for a Signal to be dispatched, I _have_ to know about a Signal instance, so if we have a bubbling child Signal, at the point we&#039;re listening to it the parent needs to implement IBubbleEventHandler and have a matching Signal itself.  This means that (in normal usage), we need to know something fairly custom about the Class involved here.

In order to dispatch our LoginEvent from our SimpleButton, we don&#039;t have to do anything but call the dispatchEvent function that it already has.  And--and--LoginView doesn&#039;t need to have any knowledge that something has happened.

To dispatch the bubbling Signal, you need to add the Signal and call its dispatch() method in the child view, then catch it and redispatch it in the parent.

From a loose coupling point of view, this all doesn&#039;t sound like better architecture.  It&#039;s not that you can&#039;t make it work, but I don&#039;t find the thing you see as so advantageous--the necessity for direct knowledge of a property on the object you want to listen to (and for parents to be so concerned about what is going on inside them)--to be a good thing in a general sense.

Anyway, like I said, I felt I owed it to those following the discussion to come back and clarify the points I may not have been very clear on before.  If I have failed this time, I apologise.  This was my best shot, and I don&#039;t see much point in continuing to discuss if it didn&#039;t work.</description>
		<content:encoded><![CDATA[<p>I debated long and hard with myself about whether to come back to this discussion. As soon as someone (even partially) declares &#8220;the debate is over and I won!&#8221; I find it hard to believe that he has a sincere interest in my point of view. However, there are others following this, so I thought I&#8217;d try one more time.</p>
<p>My husband, @SteveHoward999, says I often assume what is obvious to me is obvious to everyone, so let me go back and spell out in so many words what I believed at the outset should have been obvious, just in case it wasn&#8217;t.</p>
<p>Clint, in his original post, says: &#8220;others like myself, like to strongly type events with value objects wherever I can (resulting in many custom event classes per project).&#8221; I presumed, rightly or wrongly, that this means that he found value in these strongly typed Events&#8211;specifically, in their Value Objects.  This seams to me to be a reasonable reading of the sentence.</p>
<p>From there I said that this strong typing is lost when you use Signals. Again, it is very abundantly obvious to me, and several people have confirmed, that Signals CANNOT check that the arguments on listening functions are of the correct type, and certainly not at compile time.  This is simply due to the way that As3 handles function references.</p>
<p>By contrast, you CAN&#8217;T use dispatchEvent() to dispatch, say, a DisplayObject. So, at the very least, you know that you&#8217;re getting an Event.  I suppose that some developers have trouble constantly dispatching or listening for the wrong Event Class but, in practice, I have never encountered this problem&#8211;and I have seen a lot of truly atrocious code.</p>
<p>The simple signatures for both dispatching and receiving events make _that_ part of the process pretty idiot proof.  And the compiler will alert you if you try to add an event listener that doesn&#8217;t have at least one argument&#8211;something that you&#8217;ll only get warning of at runtime with Signals.</p>
<p>Several people have talked about the type _property_ of an Event Object as somehow being involved in its type safety. This property is, in fact, a strongly typed Object (a String), but it doesn&#8217;t matter whether you are using a strongly typed event, a regular Flash Event, or a DynamicEvent with a data property, this property always has exactly the same type safety. You can help make sure the same String is used throughout the application by using Constants, but whether those constants are used as part of the Event Class definition or not (or whether you don&#8217;t even use constants) has zero bearing on the type safety or lack therof of the property.</p>
<p>So, it was very clear to me that this was _not_ what I was saying about the type safety you throw away by not using Events.  I was actually pretty surprised to be asked to defend a position I didn&#8217;t take on this. </p>
<p>I will say this: I think that the &#8220;type&#8221; property has a very clear semantic meaning, which is &#8220;this is the specific way I want this (Class of) Event dealt with.&#8221; The Flash Player has traditionally dealt with this by routing all Events with the same type property to the same handler, without regard for the actual Class of the event.  However, the way that Robotlegs handles this, by looking at both &#8220;type&#8221; and type, proves that the semantics of the default Event object are quite workable. If the FP implementation is a bit flawed, it still works extremely well.</p>
<p>Now let&#8217;s look at the suggestion of using Signals to send an Event directly to a function. The Signal itself coopts and repeats the meaning of the Event&#8217;s type property, and this property (the only mandatory Event property) could well become meaningless.  While this might have value in retrofitting Event-based code to use Signals, in new code this has a bad smell IMO.</p>
<p>I&#8217;m going to move on to talking about my philosophy toward loose coupling, which is to use the absolutely least prescriptive Class Type needed to accomplish the job. If I have, say, a LoginView that has a SimpleButton that dispatches a bubbling LoginEvent, I can listen for that event on a LoginView instance without knowing anything about it other than it is a DisplayObject. If I needed to take it that far, I could type it as IEventDispatcher.</p>
<p>However, to listen for a Signal to be dispatched, I _have_ to know about a Signal instance, so if we have a bubbling child Signal, at the point we&#8217;re listening to it the parent needs to implement IBubbleEventHandler and have a matching Signal itself.  This means that (in normal usage), we need to know something fairly custom about the Class involved here.</p>
<p>In order to dispatch our LoginEvent from our SimpleButton, we don&#8217;t have to do anything but call the dispatchEvent function that it already has.  And&#8211;and&#8211;LoginView doesn&#8217;t need to have any knowledge that something has happened.</p>
<p>To dispatch the bubbling Signal, you need to add the Signal and call its dispatch() method in the child view, then catch it and redispatch it in the parent.</p>
<p>From a loose coupling point of view, this all doesn&#8217;t sound like better architecture.  It&#8217;s not that you can&#8217;t make it work, but I don&#8217;t find the thing you see as so advantageous&#8211;the necessity for direct knowledge of a property on the object you want to listen to (and for parents to be so concerned about what is going on inside them)&#8211;to be a good thing in a general sense.</p>
<p>Anyway, like I said, I felt I owed it to those following the discussion to come back and clarify the points I may not have been very clear on before.  If I have failed this time, I apologise.  This was my best shot, and I don&#8217;t see much point in continuing to discuss if it didn&#8217;t work.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Robert Penner</title>
		<link>http://www.pleribus.com/index.php/2010/02/replacing-events-with-as3signals/comment-page-1/#comment-1816</link>
		<dc:creator>Robert Penner</dc:creator>
		<pubDate>Tue, 31 May 2011 05:32:18 +0000</pubDate>
		<guid isPermaLink="false">http://www.pleribus.com/new_folio/?p=125#comment-1816</guid>
		<description>@Amy,

&quot;As Rob says, the way functions are treated in AS creates some fundamental weaknesses whenever you use functional techniques, and these are at the core of the problems I have with As3Signals.&quot;

How exactly do functions create problems for AS3 Signals but NOT for Events? 

Listeners for Events and Signals are basically the same. The main difference is that Signals doesn&#039;t force a certain signature (event:Event) on you. If listener references that lose type safety are bad for Signals, they&#039;re also bad for Events. 

Are you able to explain your core problems with Signals any further? So far I haven&#039;t seen anything from you re: AS functions that applies only to Signals.</description>
		<content:encoded><![CDATA[<p>@Amy,</p>
<p>&#8220;As Rob says, the way functions are treated in AS creates some fundamental weaknesses whenever you use functional techniques, and these are at the core of the problems I have with As3Signals.&#8221;</p>
<p>How exactly do functions create problems for AS3 Signals but NOT for Events? </p>
<p>Listeners for Events and Signals are basically the same. The main difference is that Signals doesn&#8217;t force a certain signature (event:Event) on you. If listener references that lose type safety are bad for Signals, they&#8217;re also bad for Events. </p>
<p>Are you able to explain your core problems with Signals any further? So far I haven&#8217;t seen anything from you re: AS functions that applies only to Signals.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Robert Penner</title>
		<link>http://www.pleribus.com/index.php/2010/02/replacing-events-with-as3signals/comment-page-1/#comment-1815</link>
		<dc:creator>Robert Penner</dc:creator>
		<pubDate>Tue, 31 May 2011 05:16:26 +0000</pubDate>
		<guid isPermaLink="false">http://www.pleribus.com/new_folio/?p=125#comment-1815</guid>
		<description>@Amy,

&quot;It looks like somewhere in there we lost track of the fact that I was originally talking about code hinting help from the IDE&quot;

Ok, help me not to lose track. Do you have other examples besides FontStylingEvent? Examples where Events allow better IDE code hinting than Signals?</description>
		<content:encoded><![CDATA[<p>@Amy,</p>
<p>&#8220;It looks like somewhere in there we lost track of the fact that I was originally talking about code hinting help from the IDE&#8221;</p>
<p>Ok, help me not to lose track. Do you have other examples besides FontStylingEvent? Examples where Events allow better IDE code hinting than Signals?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Robert Penner</title>
		<link>http://www.pleribus.com/index.php/2010/02/replacing-events-with-as3signals/comment-page-1/#comment-1814</link>
		<dc:creator>Robert Penner</dc:creator>
		<pubDate>Tue, 31 May 2011 05:11:05 +0000</pubDate>
		<guid isPermaLink="false">http://www.pleribus.com/new_folio/?p=125#comment-1814</guid>
		<description>@Amy,

&quot;If I receive an object of type FontStylingEvent, code hinting will, indeed, tell me it has a fontStyling property.&quot;

Is that really all you&#039;re talking about re: code hinting? In this case, Events don&#039;t have an advantage over Signals, which can send FontStylingEvent or anything else.

I&#039;d like to repeat my earlier question you haven&#039;t answered:

How exactly do custom Events give you more type safety than Signals? 

You said &quot;[With Signals] you’ve also given up what those custom typed events gave you–type safety&quot;. I gave several examples of how Signals improve type safety over Events. Do none of these matter to you? Is there still some pocket of functionality where you think Events have more type safety than Signals? 

Type safety was the first concern you brought up in your critique of Signals. At this point, I&#039;d consider that debunked.</description>
		<content:encoded><![CDATA[<p>@Amy,</p>
<p>&#8220;If I receive an object of type FontStylingEvent, code hinting will, indeed, tell me it has a fontStyling property.&#8221;</p>
<p>Is that really all you&#8217;re talking about re: code hinting? In this case, Events don&#8217;t have an advantage over Signals, which can send FontStylingEvent or anything else.</p>
<p>I&#8217;d like to repeat my earlier question you haven&#8217;t answered:</p>
<p>How exactly do custom Events give you more type safety than Signals? </p>
<p>You said &#8220;[With Signals] you’ve also given up what those custom typed events gave you–type safety&#8221;. I gave several examples of how Signals improve type safety over Events. Do none of these matter to you? Is there still some pocket of functionality where you think Events have more type safety than Signals? </p>
<p>Type safety was the first concern you brought up in your critique of Signals. At this point, I&#8217;d consider that debunked.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Stray</title>
		<link>http://www.pleribus.com/index.php/2010/02/replacing-events-with-as3signals/comment-page-1/#comment-1811</link>
		<dc:creator>Stray</dc:creator>
		<pubDate>Mon, 30 May 2011 20:26:55 +0000</pubDate>
		<guid isPermaLink="false">http://www.pleribus.com/new_folio/?p=125#comment-1811</guid>
		<description>&quot;The thing is, that if suddenly you decide that it’s not relevant anymore, you can’t remove the Signal without breaking whatever is listening for it–because it requres that you directly reference the Signal itself.&quot;

Yes. Correct. I interpret this as a benefit of Signals - a breaking change in terms of app behaviour is also a breaking change to the compiler. No silent just-didnt-do-what-it-was-supposed-to bugs.

&quot;I tend not to write custom events for events that do not have a payload (which are few), preferring instead to have a Class that simply defines the constants.&quot;

You mean you actually prefer strings to strong typing?</description>
		<content:encoded><![CDATA[<p>&#8220;The thing is, that if suddenly you decide that it’s not relevant anymore, you can’t remove the Signal without breaking whatever is listening for it–because it requres that you directly reference the Signal itself.&#8221;</p>
<p>Yes. Correct. I interpret this as a benefit of Signals &#8211; a breaking change in terms of app behaviour is also a breaking change to the compiler. No silent just-didnt-do-what-it-was-supposed-to bugs.</p>
<p>&#8220;I tend not to write custom events for events that do not have a payload (which are few), preferring instead to have a Class that simply defines the constants.&#8221;</p>
<p>You mean you actually prefer strings to strong typing?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Amy</title>
		<link>http://www.pleribus.com/index.php/2010/02/replacing-events-with-as3signals/comment-page-1/#comment-1810</link>
		<dc:creator>Amy</dc:creator>
		<pubDate>Mon, 30 May 2011 16:14:37 +0000</pubDate>
		<guid isPermaLink="false">http://www.pleribus.com/new_folio/?p=125#comment-1810</guid>
		<description>@Rob 

&quot;First off, thanks for the discussion. I’ll be clear that my objective isn’t to convince everyone to use AS3 Signals all the time.&quot;

You too :-). I actually have a very strong interest in Signals, especially if NativeSignal can do better filtering on native Events (not call every listener and then make them filter on event properties).  I plan to get there eventually, but I keep getting sidetracked on things that won&#039;t take me 2 solid days to do.

&quot;I wouldn’t say “no way (to know the types of arguments that will be dispatched).” If that were the case, developers would get frustrated and stop using Signals. Here are three ways people can, and do, have confidence in their listener signatures:

- documentation
- source code
- the code works without throwing a Type Coercion failure&quot;

It looks like somewhere in there we lost track of the fact that I was originally talking about code hinting help from the IDE--any time you have to go look something else or, worse, run the code to find out I&#039;ve made a mistake is going to slow me down.  Maybe I would fare better if I weren&#039;t using Flash Builder on a Mac these days, but I don&#039;t find that it makes efficient use of the screen real estate I have easy.


&quot;Events only support code hinting when [Event] metadata is used AND kept in sync with the relevant ActionScript AND a specific convention with Event constants is followed. If any of these 3 three stringy links is broken, the chain fails.&quot;

I think we&#039;re talking about two different things here.  If I receive an object of type FontStylingEvent, code hinting will, indeed, tell me it has a fontStyling property.

I usually don&#039;t care about the kind of code hinting you&#039;re talking about, because my events will either be sytem level events (dispatched against the central event bus by a Mediator, Command, or Presentation Model), or they&#039;ll be so extremely local that there&#039;s no issue taking a more direct route (looking at the code) to seeing what events are being dispatched.

When events are dispatched against the central event bus, they nearly always have a payload and thus will have a type constant defined by the custom event.  I tend not to write custom events for events that do not have a payload (which are few), preferring instead to have a Class that simply defines the constants.

I agree with everyone in this discussion that Signals is a great idea and that its weaknesses are primarily due to failures in As3.  However, those weaknesses do exist, and right now I don&#039;t find the argument for Signals compelling enough to incorporate it, though I have in a previous project with different goals and limitations.</description>
		<content:encoded><![CDATA[<p>@Rob </p>
<p>&#8220;First off, thanks for the discussion. I’ll be clear that my objective isn’t to convince everyone to use AS3 Signals all the time.&#8221;</p>
<p>You too <img src='http://www.pleribus.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> . I actually have a very strong interest in Signals, especially if NativeSignal can do better filtering on native Events (not call every listener and then make them filter on event properties).  I plan to get there eventually, but I keep getting sidetracked on things that won&#8217;t take me 2 solid days to do.</p>
<p>&#8220;I wouldn’t say “no way (to know the types of arguments that will be dispatched).” If that were the case, developers would get frustrated and stop using Signals. Here are three ways people can, and do, have confidence in their listener signatures:</p>
<p>- documentation<br />
- source code<br />
- the code works without throwing a Type Coercion failure&#8221;</p>
<p>It looks like somewhere in there we lost track of the fact that I was originally talking about code hinting help from the IDE&#8211;any time you have to go look something else or, worse, run the code to find out I&#8217;ve made a mistake is going to slow me down.  Maybe I would fare better if I weren&#8217;t using Flash Builder on a Mac these days, but I don&#8217;t find that it makes efficient use of the screen real estate I have easy.</p>
<p>&#8220;Events only support code hinting when [Event] metadata is used AND kept in sync with the relevant ActionScript AND a specific convention with Event constants is followed. If any of these 3 three stringy links is broken, the chain fails.&#8221;</p>
<p>I think we&#8217;re talking about two different things here.  If I receive an object of type FontStylingEvent, code hinting will, indeed, tell me it has a fontStyling property.</p>
<p>I usually don&#8217;t care about the kind of code hinting you&#8217;re talking about, because my events will either be sytem level events (dispatched against the central event bus by a Mediator, Command, or Presentation Model), or they&#8217;ll be so extremely local that there&#8217;s no issue taking a more direct route (looking at the code) to seeing what events are being dispatched.</p>
<p>When events are dispatched against the central event bus, they nearly always have a payload and thus will have a type constant defined by the custom event.  I tend not to write custom events for events that do not have a payload (which are few), preferring instead to have a Class that simply defines the constants.</p>
<p>I agree with everyone in this discussion that Signals is a great idea and that its weaknesses are primarily due to failures in As3.  However, those weaknesses do exist, and right now I don&#8217;t find the argument for Signals compelling enough to incorporate it, though I have in a previous project with different goals and limitations.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Amy</title>
		<link>http://www.pleribus.com/index.php/2010/02/replacing-events-with-as3signals/comment-page-1/#comment-1808</link>
		<dc:creator>Amy</dc:creator>
		<pubDate>Mon, 30 May 2011 15:49:16 +0000</pubDate>
		<guid isPermaLink="false">http://www.pleribus.com/new_folio/?p=125#comment-1808</guid>
		<description>I&#039;m going to start with @Stray, because she and I seem to enjoy having spirited debates on a regular basis :-).

&quot;There is a clear conceptual difference between ‘not dispatching’, because the implementation has blocked it, and ‘never relevant’.&quot;

The thing is, that if suddenly you decide that it&#039;s not relevant anymore, you can&#039;t remove the Signal without breaking whatever is listening for it--because it requres that you directly reference the Signal itself.  I know that things like the SignalCommandMap somewhat alleviate this, but I&#039;m talking about in normal use.

If you remove code that dispatches an event, all the code that was intended to trigger when it fires is still relevant and could be called upon if you change your program again.

&quot;As Rob says, it means when I add a listener to a custom object I often have to start referring to the AS3 reference to check exactly what event is dispatched when by this object.&quot;

...and you have to look at the Signal to see what data types will appear in the arguments list.  I think that&#039;s pretty much a wash.

&quot;(I realise that I could do the same by having multiple event strings, but much less elegantly for the user of the API).&quot;

Some users find needing an additional Library inelegant compared to using constants that the IDE will mostly type for them anyway.

&quot;With events, I either have to create and dispatch a different event for each click, or I have to expose those buttons (which opens up all their properties: position, enabled, alpha yada yada) to something that wants to listen for the clicks on them. Or I can bubble the event and do a switch on the target – and again this target means that I have access to set any property of that button.&quot;

Or you can use PresentationModel, and allow the PM to determine the meaning of the gesture (which is roughly equivalent to what you&#039;re doing in Signals, but carries some other functionality as well that you might find advantagous or not).

&quot;(Approaches such as only adding the response handler locally don’t work because you’re then relying on order-of-executions and assuming only one request at a time).&quot;

You might want to look at the way AsyncToken works in Flex and see if that isn&#039;t a better way to handle it.

&quot;I’m intrigued that you’d be so invested in slating an approach that so many people are finding to be useful.&quot;

That&#039;s kind of a harsh interpretation of what I consider a simple discussion of the pros and cons of a specifc technology.  But the reason I&#039;m willing to look at the other side of this is the same reason I&#039;m willing to reevaluate the truism that anonymous functions are always bad or any of those other things we&#039;re asked to believe are true.

&quot;Mindful choices allow us to be more intentional in our architecture and implementation.&quot;

Precisely. And for what I&#039;m doing now, at least, the other techniques I am using serve me every bit as well as using As3Signals, without introducing yet another library.  I would encourage others to be very thorough in their evaluation of what they get with As3Signals vs. what they lose.  

As Rob says, the way functions are treated in AS creates some fundamental weaknesses whenever you use functional techniques, and these are at the core of the problems I have with As3Signals.  Personally, I would have preferred that Adobe move addressing these above trying to add multithreading, but they didn&#039;t AFAIK.</description>
		<content:encoded><![CDATA[<p>I&#8217;m going to start with @Stray, because she and I seem to enjoy having spirited debates on a regular basis <img src='http://www.pleribus.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> .</p>
<p>&#8220;There is a clear conceptual difference between ‘not dispatching’, because the implementation has blocked it, and ‘never relevant’.&#8221;</p>
<p>The thing is, that if suddenly you decide that it&#8217;s not relevant anymore, you can&#8217;t remove the Signal without breaking whatever is listening for it&#8211;because it requres that you directly reference the Signal itself.  I know that things like the SignalCommandMap somewhat alleviate this, but I&#8217;m talking about in normal use.</p>
<p>If you remove code that dispatches an event, all the code that was intended to trigger when it fires is still relevant and could be called upon if you change your program again.</p>
<p>&#8220;As Rob says, it means when I add a listener to a custom object I often have to start referring to the AS3 reference to check exactly what event is dispatched when by this object.&#8221;</p>
<p>&#8230;and you have to look at the Signal to see what data types will appear in the arguments list.  I think that&#8217;s pretty much a wash.</p>
<p>&#8220;(I realise that I could do the same by having multiple event strings, but much less elegantly for the user of the API).&#8221;</p>
<p>Some users find needing an additional Library inelegant compared to using constants that the IDE will mostly type for them anyway.</p>
<p>&#8220;With events, I either have to create and dispatch a different event for each click, or I have to expose those buttons (which opens up all their properties: position, enabled, alpha yada yada) to something that wants to listen for the clicks on them. Or I can bubble the event and do a switch on the target – and again this target means that I have access to set any property of that button.&#8221;</p>
<p>Or you can use PresentationModel, and allow the PM to determine the meaning of the gesture (which is roughly equivalent to what you&#8217;re doing in Signals, but carries some other functionality as well that you might find advantagous or not).</p>
<p>&#8220;(Approaches such as only adding the response handler locally don’t work because you’re then relying on order-of-executions and assuming only one request at a time).&#8221;</p>
<p>You might want to look at the way AsyncToken works in Flex and see if that isn&#8217;t a better way to handle it.</p>
<p>&#8220;I’m intrigued that you’d be so invested in slating an approach that so many people are finding to be useful.&#8221;</p>
<p>That&#8217;s kind of a harsh interpretation of what I consider a simple discussion of the pros and cons of a specifc technology.  But the reason I&#8217;m willing to look at the other side of this is the same reason I&#8217;m willing to reevaluate the truism that anonymous functions are always bad or any of those other things we&#8217;re asked to believe are true.</p>
<p>&#8220;Mindful choices allow us to be more intentional in our architecture and implementation.&#8221;</p>
<p>Precisely. And for what I&#8217;m doing now, at least, the other techniques I am using serve me every bit as well as using As3Signals, without introducing yet another library.  I would encourage others to be very thorough in their evaluation of what they get with As3Signals vs. what they lose.  </p>
<p>As Rob says, the way functions are treated in AS creates some fundamental weaknesses whenever you use functional techniques, and these are at the core of the problems I have with As3Signals.  Personally, I would have preferred that Adobe move addressing these above trying to add multithreading, but they didn&#8217;t AFAIK.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Stray</title>
		<link>http://www.pleribus.com/index.php/2010/02/replacing-events-with-as3signals/comment-page-1/#comment-1805</link>
		<dc:creator>Stray</dc:creator>
		<pubDate>Mon, 30 May 2011 11:31:20 +0000</pubDate>
		<guid isPermaLink="false">http://www.pleribus.com/new_folio/?p=125#comment-1805</guid>
		<description>Amy said: &quot;... really, there is nothing that says that a Class that declares a closeMe Signal will ever dispatch it–just that it _may_, which is exactly the same guarantee you get from Events.&quot;

Amy - that misses the point. There is a clear conceptual difference between &#039;not dispatching&#039;, because the implementation has blocked it, and &#039;never relevant&#039;.  

I can, of course, choose to have my signal implementation not actually dispatch a particular signal - just as with events - but I can&#039;t choose to listen for a signal which has no relevance to that object.

If I want to, I can listen for a MouseEvent.CLICK on any IEventDispatcher - including a model which has no presence on the display list. I can listen for Video events on an XML loading service. This is broken. 

As Rob says, it means when I add a listener to a custom object I often have to start referring to the AS3 reference to check exactly what event is dispatched when by this object.

Even with event hinting, I get very little information to help me figure out - for example - whether there is a progress event dispatched after complete, always immediately before it, or only sometimes immediately before it.

With signals I can create beautifully expressive getters that make this obvious, with very little extra overhead:

progressUpdateBeforeComplete
progressUpdateAfterComplete

(I realise that I could do the same by having multiple event strings, but much less elegantly for the user of the API).


However, my own favourite thing about Signals is using them in composite views. Let&#039;s say our view is a login panel with 3 buttons - &#039;submit&#039;, &#039;quit&#039; and &#039;forgot password&#039;. With events, I either have to create and dispatch a different event for each click, or I have to expose those buttons (which opens up all their properties: position, enabled, alpha yada yada) to something that wants to listen for the clicks on them.  Or I can bubble the event and do a switch on the target - and again this target means that I have access to set any property of that button.

With signals I can just add 3 simple signals to the parent view - one for each click.

In my opinion, the signals approach is closer to the kind of &#039;need to know&#039; basis that I want my code to work on. Does the listener need to move these buttons around? Does it need to shift them in position? No - it just needs to know when they&#039;ve been clicked. *If* it wants the buttons to move or change alpha then it should go through an API on the parent.

Personally I still use a mix of events and signals. I&#039;ve done a lot more than &#039;play around with&#039; Signals - I use them in our production code all the time. They are incredibly useful - for example - for implementing a type-safe-at-runtime (ie easy to debug) request-response pattern allowing a specific instance of a class to receive an async update on its own schedule, without having to do horrible hacky workarounds such as arbitrary IDs on events. (Approaches such as only adding the response handler locally don&#039;t work because you&#039;re then relying on order-of-executions and assuming only one request at a time).

I&#039;m intrigued that you&#039;d be so invested in slating an approach that so many people are finding to be useful. Putting all the implementation details aside, there are 3 things we know for sure about signals:

1) They&#039;re the product of an enormous amount of energy invested by numerous very smart people over a long period of time. (Robert hasn&#039;t just been locked in his attic working on a secret master plan).

2) The process of developing them has been done in the open with lots of healthy discussion, debate, testing, heuristic feedback, revision, refactoring, branching (to consider the merits of alternative approaches) and intentional reflection by the community.

3) They offer a different approach to achieving loose coupling between objects, with solutions for some of the problems that have irked many programmers about the AS3 events system.

What&#039;s to object to? Provided A and B are both of high quality, having a choice between A and B is a useful thing IMO. Mindful choices allow us to be more intentional in our architecture and implementation. Even if neither A nor B is perfect, having alternatives with different strengths and weaknesses allows us to optimise.</description>
		<content:encoded><![CDATA[<p>Amy said: &#8220;&#8230; really, there is nothing that says that a Class that declares a closeMe Signal will ever dispatch it–just that it _may_, which is exactly the same guarantee you get from Events.&#8221;</p>
<p>Amy &#8211; that misses the point. There is a clear conceptual difference between &#8216;not dispatching&#8217;, because the implementation has blocked it, and &#8216;never relevant&#8217;.  </p>
<p>I can, of course, choose to have my signal implementation not actually dispatch a particular signal &#8211; just as with events &#8211; but I can&#8217;t choose to listen for a signal which has no relevance to that object.</p>
<p>If I want to, I can listen for a MouseEvent.CLICK on any IEventDispatcher &#8211; including a model which has no presence on the display list. I can listen for Video events on an XML loading service. This is broken. </p>
<p>As Rob says, it means when I add a listener to a custom object I often have to start referring to the AS3 reference to check exactly what event is dispatched when by this object.</p>
<p>Even with event hinting, I get very little information to help me figure out &#8211; for example &#8211; whether there is a progress event dispatched after complete, always immediately before it, or only sometimes immediately before it.</p>
<p>With signals I can create beautifully expressive getters that make this obvious, with very little extra overhead:</p>
<p>progressUpdateBeforeComplete<br />
progressUpdateAfterComplete</p>
<p>(I realise that I could do the same by having multiple event strings, but much less elegantly for the user of the API).</p>
<p>However, my own favourite thing about Signals is using them in composite views. Let&#8217;s say our view is a login panel with 3 buttons &#8211; &#8217;submit&#8217;, &#8216;quit&#8217; and &#8216;forgot password&#8217;. With events, I either have to create and dispatch a different event for each click, or I have to expose those buttons (which opens up all their properties: position, enabled, alpha yada yada) to something that wants to listen for the clicks on them.  Or I can bubble the event and do a switch on the target &#8211; and again this target means that I have access to set any property of that button.</p>
<p>With signals I can just add 3 simple signals to the parent view &#8211; one for each click.</p>
<p>In my opinion, the signals approach is closer to the kind of &#8216;need to know&#8217; basis that I want my code to work on. Does the listener need to move these buttons around? Does it need to shift them in position? No &#8211; it just needs to know when they&#8217;ve been clicked. *If* it wants the buttons to move or change alpha then it should go through an API on the parent.</p>
<p>Personally I still use a mix of events and signals. I&#8217;ve done a lot more than &#8216;play around with&#8217; Signals &#8211; I use them in our production code all the time. They are incredibly useful &#8211; for example &#8211; for implementing a type-safe-at-runtime (ie easy to debug) request-response pattern allowing a specific instance of a class to receive an async update on its own schedule, without having to do horrible hacky workarounds such as arbitrary IDs on events. (Approaches such as only adding the response handler locally don&#8217;t work because you&#8217;re then relying on order-of-executions and assuming only one request at a time).</p>
<p>I&#8217;m intrigued that you&#8217;d be so invested in slating an approach that so many people are finding to be useful. Putting all the implementation details aside, there are 3 things we know for sure about signals:</p>
<p>1) They&#8217;re the product of an enormous amount of energy invested by numerous very smart people over a long period of time. (Robert hasn&#8217;t just been locked in his attic working on a secret master plan).</p>
<p>2) The process of developing them has been done in the open with lots of healthy discussion, debate, testing, heuristic feedback, revision, refactoring, branching (to consider the merits of alternative approaches) and intentional reflection by the community.</p>
<p>3) They offer a different approach to achieving loose coupling between objects, with solutions for some of the problems that have irked many programmers about the AS3 events system.</p>
<p>What&#8217;s to object to? Provided A and B are both of high quality, having a choice between A and B is a useful thing IMO. Mindful choices allow us to be more intentional in our architecture and implementation. Even if neither A nor B is perfect, having alternatives with different strengths and weaknesses allows us to optimise.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Robert Penner</title>
		<link>http://www.pleribus.com/index.php/2010/02/replacing-events-with-as3signals/comment-page-1/#comment-1803</link>
		<dc:creator>Robert Penner</dc:creator>
		<pubDate>Mon, 30 May 2011 03:22:45 +0000</pubDate>
		<guid isPermaLink="false">http://www.pleribus.com/new_folio/?p=125#comment-1803</guid>
		<description>@Amy, first off, thanks for the discussion. I&#039;ll be clear that my objective isn&#039;t to convince everyone to use AS3 Signals all the time. Rather, it&#039;s to debate open questions about their merits relative to alternatives such as Events.  

&quot;Signals has no way for me to be sure that the types on the arguments of my _receiving_ function are the same as what are being dispatched.&quot;

I wouldn&#039;t say &quot;no way.&quot; If that were the case, developers would get frustrated and stop using Signals. Here are three ways people can, and do, have confidence in their listener signatures:

- documentation
- source code
- the code works without throwing a Type Coercion failure

Could it be better? Yes, if ActionScript were improved with generics and stronger function types.

Let me throw this back at Events: How can you be sure your listener Event argument is correct? The compiler certainly doesn&#039;t help you. It takes extra metadata and convention following to achieve this. Personally, with Events I find myself bouncing around asdocs a lot tracking down which constants to use.

&quot;Worse, there is no code hinting.&quot;

The name of the Signal is code hinted, enabling the compiler to guarantee you&#039;re listening to something valid. This is something Events cannot do. However, the Signal signature is not code hinted, due to limitations of ActionScript. 

Events only support code hinting when [Event] metadata is used AND kept in sync with the relevant ActionScript AND a specific convention with Event constants is followed. If any of these 3 three stringy links is broken, the chain fails.

AS3 Signals could use metadata to achieve the same level of code hinting as Events. As of yet, though, it&#039;s not something the community has demanded. We seem to manage fine without adding extra stuff that has to be maintained and kept in sync with the real code.</description>
		<content:encoded><![CDATA[<p>@Amy, first off, thanks for the discussion. I&#8217;ll be clear that my objective isn&#8217;t to convince everyone to use AS3 Signals all the time. Rather, it&#8217;s to debate open questions about their merits relative to alternatives such as Events.  </p>
<p>&#8220;Signals has no way for me to be sure that the types on the arguments of my _receiving_ function are the same as what are being dispatched.&#8221;</p>
<p>I wouldn&#8217;t say &#8220;no way.&#8221; If that were the case, developers would get frustrated and stop using Signals. Here are three ways people can, and do, have confidence in their listener signatures:</p>
<p>- documentation<br />
- source code<br />
- the code works without throwing a Type Coercion failure</p>
<p>Could it be better? Yes, if ActionScript were improved with generics and stronger function types.</p>
<p>Let me throw this back at Events: How can you be sure your listener Event argument is correct? The compiler certainly doesn&#8217;t help you. It takes extra metadata and convention following to achieve this. Personally, with Events I find myself bouncing around asdocs a lot tracking down which constants to use.</p>
<p>&#8220;Worse, there is no code hinting.&#8221;</p>
<p>The name of the Signal is code hinted, enabling the compiler to guarantee you&#8217;re listening to something valid. This is something Events cannot do. However, the Signal signature is not code hinted, due to limitations of ActionScript. </p>
<p>Events only support code hinting when [Event] metadata is used AND kept in sync with the relevant ActionScript AND a specific convention with Event constants is followed. If any of these 3 three stringy links is broken, the chain fails.</p>
<p>AS3 Signals could use metadata to achieve the same level of code hinting as Events. As of yet, though, it&#8217;s not something the community has demanded. We seem to manage fine without adding extra stuff that has to be maintained and kept in sync with the real code.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

