<?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"
	>
<channel>
	<title>Comments on: Runtime Checks for Abstract Classes and Methods in ActionScript 3.0</title>
	<atom:link href="http://www.as3dp.com/2007/05/05/runtime-checks-for-abstract-classes-and-methods-in-actionscript-30/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.as3dp.com/2007/05/05/runtime-checks-for-abstract-classes-and-methods-in-actionscript-30/</link>
	<description>OOP for Flash, Flex and AIR</description>
	<pubDate>Mon, 08 Sep 2008 14:46:14 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.6.1</generator>
		<item>
		<title>By: chandima</title>
		<link>http://www.as3dp.com/2007/05/05/runtime-checks-for-abstract-classes-and-methods-in-actionscript-30/#comment-486</link>
		<dc:creator>chandima</dc:creator>
		<pubDate>Fri, 08 Feb 2008 17:43:32 +0000</pubDate>
		<guid isPermaLink="false">http://www.as3dp.com/?p=9#comment-486</guid>
		<description>Hi Kevin,

Thanks for the insightful comments - I agree 100% with everything you said. This was more like a "Look! abstract classes in AS3" exercise than a robust solution. I myself, just name abstract classes in AS starting with the word "Abstract", heavily comment stuff, and rarely throw any runtime exceptions.

Like you, I'm hoping that abstract classes will be baked into future versions of AS. However, I don't see any movement in that direction in the ECMA proposals :/</description>
		<content:encoded><![CDATA[<p>Hi Kevin,</p>
<p>Thanks for the insightful comments - I agree 100% with everything you said. This was more like a &#8220;Look! abstract classes in AS3&#8243; exercise than a robust solution. I myself, just name abstract classes in AS starting with the word &#8220;Abstract&#8221;, heavily comment stuff, and rarely throw any runtime exceptions.</p>
<p>Like you, I&#8217;m hoping that abstract classes will be baked into future versions of AS. However, I don&#8217;t see any movement in that direction in the ECMA proposals :/</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Kevin Freund</title>
		<link>http://www.as3dp.com/2007/05/05/runtime-checks-for-abstract-classes-and-methods-in-actionscript-30/#comment-481</link>
		<dc:creator>Kevin Freund</dc:creator>
		<pubDate>Thu, 07 Feb 2008 07:14:24 +0000</pubDate>
		<guid isPermaLink="false">http://www.as3dp.com/?p=9#comment-481</guid>
		<description>Folks, this works all well and good, but three comments:

This could should always be wrapped in something like "if (Debug)" to slap any of your developer peers who may not understand the abstract pattern; you wouldn't want to enable this code in production because:
     1) it's inefficient;
     2) if you catch this in production, it's too late to do anything about what should have been a compile-time exception anyway.

Chandima, the type introspection you do in the above code only works if you scope your virtual functions as "public".  At times this is somewhat inconvenient, since you may want to protect your functions from the above mentioned developer peers (you know who they are) who try to call your functions out of context.

Mims, although it is possible that I haven't seen your latest code, it seems to me that you are only enforcing 50% of what an abstract class  requires.  In addition to the prohibition of the abstract class being instantiated (which you do correctly), a subclass of an abstract class must implement ALL of the virtual functions of the abstract class.  With your code, you only throw an exception if the virtual method is called directly (because that particular method has no override).  With this implementation, the oversight of overriding a single virtual function among many may not pop up while you're developing (if you don't test every possible use case).  I like Chandima's solution which front-loads all the checks using type introspection.

In summary, I've found implementing this pattern in AS3 to be a real pain in the butt, not to mention an ugly hack at best.  I'm definitely putting my vote in for the abstract keyword in AS4.</description>
		<content:encoded><![CDATA[<p>Folks, this works all well and good, but three comments:</p>
<p>This could should always be wrapped in something like &#8220;if (Debug)&#8221; to slap any of your developer peers who may not understand the abstract pattern; you wouldn&#8217;t want to enable this code in production because:<br />
     1) it&#8217;s inefficient;<br />
     2) if you catch this in production, it&#8217;s too late to do anything about what should have been a compile-time exception anyway.</p>
<p>Chandima, the type introspection you do in the above code only works if you scope your virtual functions as &#8220;public&#8221;.  At times this is somewhat inconvenient, since you may want to protect your functions from the above mentioned developer peers (you know who they are) who try to call your functions out of context.</p>
<p>Mims, although it is possible that I haven&#8217;t seen your latest code, it seems to me that you are only enforcing 50% of what an abstract class  requires.  In addition to the prohibition of the abstract class being instantiated (which you do correctly), a subclass of an abstract class must implement ALL of the virtual functions of the abstract class.  With your code, you only throw an exception if the virtual method is called directly (because that particular method has no override).  With this implementation, the oversight of overriding a single virtual function among many may not pop up while you&#8217;re developing (if you don&#8217;t test every possible use case).  I like Chandima&#8217;s solution which front-loads all the checks using type introspection.</p>
<p>In summary, I&#8217;ve found implementing this pattern in AS3 to be a real pain in the butt, not to mention an ugly hack at best.  I&#8217;m definitely putting my vote in for the abstract keyword in AS4.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mims Wright</title>
		<link>http://www.as3dp.com/2007/05/05/runtime-checks-for-abstract-classes-and-methods-in-actionscript-30/#comment-2</link>
		<dc:creator>Mims Wright</dc:creator>
		<pubDate>Fri, 11 May 2007 21:53:46 +0000</pubDate>
		<guid isPermaLink="false">http://www.as3dp.com/?p=9#comment-2</guid>
		<description>Hey Chandima,

I actually did figure out a way to enforce methods as well as classes with my implementation. The AbstractEnforcer class contains two methods, 
AbstractEnforcer.enforceConstructor() for making a constructor abstract
and 
AbstractEnforcer.enforceMethod() for making a method abstract.
You can use both independently of each other - in other words, you can have an abstract method without having an abstract class. 
Both work at runtime. What would be really great is to get one that works at compile time but I haven't figured that out yet. 
Your solution is interesting too. There's probably more to learn from the introspection that I haven't found yet.

Mims</description>
		<content:encoded><![CDATA[<p>Hey Chandima,</p>
<p>I actually did figure out a way to enforce methods as well as classes with my implementation. The AbstractEnforcer class contains two methods,<br />
AbstractEnforcer.enforceConstructor() for making a constructor abstract<br />
and<br />
AbstractEnforcer.enforceMethod() for making a method abstract.<br />
You can use both independently of each other - in other words, you can have an abstract method without having an abstract class.<br />
Both work at runtime. What would be really great is to get one that works at compile time but I haven&#8217;t figured that out yet.<br />
Your solution is interesting too. There&#8217;s probably more to learn from the introspection that I haven&#8217;t found yet.</p>
<p>Mims</p>
]]></content:encoded>
	</item>
</channel>
</rss>
