<?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: A coding challenge</title>
	<atom:link href="http://flexblog.faratasystems.com/2006/10/09/a-coding-challenge/feed" rel="self" type="application/rss+xml" />
	<link>http://flexblog.faratasystems.com/2006/10/09/a-coding-challenge</link>
	<description>A blog about our experience with Adobe Flex</description>
	<lastBuildDate>Sun, 15 Jan 2012 16:29:29 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Tom Chiverton</title>
		<link>http://flexblog.faratasystems.com/2006/10/09/a-coding-challenge/comment-page-1#comment-516</link>
		<dc:creator>Tom Chiverton</dc:creator>
		<pubDate>Wed, 01 Nov 2006 10:00:46 +0000</pubDate>
		<guid isPermaLink="false">http://flexblog.faratasystems.com/?p=98#comment-516</guid>
		<description>(pardon my last comment)
Why wouldn&#039;t I have hasIncreasePay():Bool and increasePay(int):void methods ?</description>
		<content:encoded><![CDATA[<p>(pardon my last comment)<br />
Why wouldn&#8217;t I have hasIncreasePay():Bool and increasePay(int):void methods ?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Tom Chiverton</title>
		<link>http://flexblog.faratasystems.com/2006/10/09/a-coding-challenge/comment-page-1#comment-515</link>
		<dc:creator>Tom Chiverton</dc:creator>
		<pubDate>Wed, 01 Nov 2006 09:59:48 +0000</pubDate>
		<guid isPermaLink="false">http://flexblog.faratasystems.com/?p=98#comment-515</guid>
		<description>http://anjalixz.tripod.com/renderer3d/Example3da.html</description>
		<content:encoded><![CDATA[<p><a href="http://anjalixz.tripod.com/renderer3d/Example3da.html" rel="nofollow">http://anjalixz.tripod.com/renderer3d/Example3da.html</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Evert</title>
		<link>http://flexblog.faratasystems.com/2006/10/09/a-coding-challenge/comment-page-1#comment-455</link>
		<dc:creator>Evert</dc:creator>
		<pubDate>Tue, 31 Oct 2006 07:37:59 +0000</pubDate>
		<guid isPermaLink="false">http://flexblog.faratasystems.com/?p=98#comment-455</guid>
		<description>This is called duck-typing</description>
		<content:encoded><![CDATA[<p>This is called duck-typing</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Barney Boisvert</title>
		<link>http://flexblog.faratasystems.com/2006/10/09/a-coding-challenge/comment-page-1#comment-451</link>
		<dc:creator>Barney Boisvert</dc:creator>
		<pubDate>Tue, 31 Oct 2006 05:52:50 +0000</pubDate>
		<guid isPermaLink="false">http://flexblog.faratasystems.com/?p=98#comment-451</guid>
		<description>View source on my previous comment to get the rest of it.  No HTML escaping provided automatically, it seems, so my &lt; got interpreted literally.  To test......

alert(&quot;uh, oh!&quot;);</description>
		<content:encoded><![CDATA[<p>View source on my previous comment to get the rest of it.  No HTML escaping provided automatically, it seems, so my &lt; got interpreted literally.  To test&#8230;&#8230;</p>
<p>alert(&#8220;uh, oh!&#8221;);</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Barney Boisvert</title>
		<link>http://flexblog.faratasystems.com/2006/10/09/a-coding-challenge/comment-page-1#comment-450</link>
		<dc:creator>Barney Boisvert</dc:creator>
		<pubDate>Tue, 31 Oct 2006 05:50:40 +0000</pubDate>
		<guid isPermaLink="false">http://flexblog.faratasystems.com/?p=98#comment-450</guid>
		<description>It&#039;s written that way because reducing lines of code was more important than readability  For each worker, increase their pay by 5, if possible, appending the result to the output.  Otherwise append &quot;no luck&quot; to the output.  How about this version:

for(var i:uint = 0; i </description>
		<content:encoded><![CDATA[<p>It&#8217;s written that way because reducing lines of code was more important than readability  For each worker, increase their pay by 5, if possible, appending the result to the output.  Otherwise append &#8220;no luck&#8221; to the output.  How about this version:</p>
<p>for(var i:uint = 0; i</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: erenbali</title>
		<link>http://flexblog.faratasystems.com/2006/10/09/a-coding-challenge/comment-page-1#comment-212</link>
		<dc:creator>erenbali</dc:creator>
		<pubDate>Tue, 24 Oct 2006 13:52:34 +0000</pubDate>
		<guid isPermaLink="false">http://flexblog.faratasystems.com/?p=98#comment-212</guid>
		<description>here is my guess if i&#039;m not that much late.

there is a base class Worker of lets say all workers in a company. there are some other classes extending Worker like Secretary, Engineer, Manager.. Let&#039;s say just Manager and Engineer classes implement increasePay function. 

In such a situation we would probably keep an array of workers in the company for some batch processing needs(f.e paySalary..)
these loop increasesPay of the workers that can increasePay</description>
		<content:encoded><![CDATA[<p>here is my guess if i&#8217;m not that much late.</p>
<p>there is a base class Worker of lets say all workers in a company. there are some other classes extending Worker like Secretary, Engineer, Manager.. Let&#8217;s say just Manager and Engineer classes implement increasePay function. </p>
<p>In such a situation we would probably keep an array of workers in the company for some batch processing needs(f.e paySalary..)<br />
these loop increasesPay of the workers that can increasePay</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: francis bourre</title>
		<link>http://flexblog.faratasystems.com/2006/10/09/a-coding-challenge/comment-page-1#comment-52</link>
		<dc:creator>francis bourre</dc:creator>
		<pubDate>Thu, 12 Oct 2006 16:07:31 +0000</pubDate>
		<guid isPermaLink="false">http://flexblog.faratasystems.com/?p=98#comment-52</guid>
		<description>last but not least, polymorphism with interfaces allow precompilation error checking.
Does this old-school obfuscated code snippet tries to highlight bad code practices ? :p</description>
		<content:encoded><![CDATA[<p>last but not least, polymorphism with interfaces allow precompilation error checking.<br />
Does this old-school obfuscated code snippet tries to highlight bad code practices ? :p</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Yakov Fain</title>
		<link>http://flexblog.faratasystems.com/2006/10/09/a-coding-challenge/comment-page-1#comment-42</link>
		<dc:creator>Yakov Fain</dc:creator>
		<pubDate>Mon, 09 Oct 2006 16:34:47 +0000</pubDate>
		<guid isPermaLink="false">http://flexblog.faratasystems.com/?p=98#comment-42</guid>
		<description>I&#039;ve emailed my e-book to Dirk ans spender already for providing more detailed answers than others.

I&#039;ll be happy to give away more copies of the e-book to those of you who will provide detailed explanations of why some particular syntax constructs were used in this example. Just analyze each line of this code and provide your reasoning/alternatives.</description>
		<content:encoded><![CDATA[<p>I&#8217;ve emailed my e-book to Dirk ans spender already for providing more detailed answers than others.</p>
<p>I&#8217;ll be happy to give away more copies of the e-book to those of you who will provide detailed explanations of why some particular syntax constructs were used in this example. Just analyze each line of this code and provide your reasoning/alternatives.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Kristof</title>
		<link>http://flexblog.faratasystems.com/2006/10/09/a-coding-challenge/comment-page-1#comment-41</link>
		<dc:creator>Kristof</dc:creator>
		<pubDate>Mon, 09 Oct 2006 15:56:02 +0000</pubDate>
		<guid isPermaLink="false">http://flexblog.faratasystems.com/?p=98#comment-41</guid>
		<description>//you could also write it like this
//I&#039;ll leave the implementation of implementsMethod to you
for(var i:uint = 0; i </description>
		<content:encoded><![CDATA[<p>//you could also write it like this<br />
//I&#8217;ll leave the implementation of implementsMethod to you<br />
for(var i:uint = 0; i</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dirk</title>
		<link>http://flexblog.faratasystems.com/2006/10/09/a-coding-challenge/comment-page-1#comment-40</link>
		<dc:creator>Dirk</dc:creator>
		<pubDate>Mon, 09 Oct 2006 15:48:53 +0000</pubDate>
		<guid isPermaLink="false">http://flexblog.faratasystems.com/?p=98#comment-40</guid>
		<description>Aside from the typo (should be workers[i] instead of worker[i] I think) here&#039;s my try: 

the approach illustrates how to invoke common methods on objects that don&#039;t have to share a common type. So instead of checking each worker object against a type (or interface), the construct tries to resolve increasePay on the current object. As this dynamic construct either evaluates to undefined or a Function reference, the shorthand if/else is then used to invoke p (in this example a Function reference) with an argument and return its return value or just uses a default String return value if the method increasePay cannot be resolved.

Of course, if the object implements a ”increasePay” field which is not a Function object but e.g. a String, then this causes a runtime error.</description>
		<content:encoded><![CDATA[<p>Aside from the typo (should be workers[i] instead of worker[i] I think) here&#8217;s my try: </p>
<p>the approach illustrates how to invoke common methods on objects that don&#8217;t have to share a common type. So instead of checking each worker object against a type (or interface), the construct tries to resolve increasePay on the current object. As this dynamic construct either evaluates to undefined or a Function reference, the shorthand if/else is then used to invoke p (in this example a Function reference) with an argument and return its return value or just uses a default String return value if the method increasePay cannot be resolved.</p>
<p>Of course, if the object implements a ”increasePay” field which is not a Function object but e.g. a String, then this causes a runtime error.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: spender</title>
		<link>http://flexblog.faratasystems.com/2006/10/09/a-coding-challenge/comment-page-1#comment-38</link>
		<dc:creator>spender</dc:creator>
		<pubDate>Mon, 09 Oct 2006 14:56:34 +0000</pubDate>
		<guid isPermaLink="false">http://flexblog.faratasystems.com/?p=98#comment-38</guid>
		<description>I guess the reason you didn&#039;t use an interface is because the title of your article is &quot;Polymorphism Without Interfaces&quot;. Doh!

You still need to check that (p is Function) rather than if (p==undefined)... ideally you&#039;d introspect to check that the signature of p is p(n:Number) as well. Pretty messy if you ask me!

/spender</description>
		<content:encoded><![CDATA[<p>I guess the reason you didn&#8217;t use an interface is because the title of your article is &#8220;Polymorphism Without Interfaces&#8221;. Doh!</p>
<p>You still need to check that (p is Function) rather than if (p==undefined)&#8230; ideally you&#8217;d introspect to check that the signature of p is p(n:Number) as well. Pretty messy if you ask me!</p>
<p>/spender</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: spender</title>
		<link>http://flexblog.faratasystems.com/2006/10/09/a-coding-challenge/comment-page-1#comment-37</link>
		<dc:creator>spender</dc:creator>
		<pubDate>Mon, 09 Oct 2006 14:46:27 +0000</pubDate>
		<guid isPermaLink="false">http://flexblog.faratasystems.com/?p=98#comment-37</guid>
		<description>The code iterates through an array (workers).
For each object in the array, you are testing to see if it has a property called increasePay
If the object has a property increasePay, you treat it as if it were a function (although this is not checked), and invoke it, and append the result to the string output.text. If it does not have the property increasePay, then you add &quot;no luck&quot; to the string output.text instead.

So, the intent of the code (although without checking p to see if it is a Function object, I&#039;d venture that the code is incomplete), is to check if the objects in the array support the function increasePay. If so, you take further action.

Wouldn&#039;t it be better to have the objects implement an interface defining increasePay, (e.g. IPayRiseable)? That way you could check:

if(worker[i] is IPayRiseable)
{
   worker[i].increasePay(5);
}

I like your blog, btw.

Cheers.</description>
		<content:encoded><![CDATA[<p>The code iterates through an array (workers).<br />
For each object in the array, you are testing to see if it has a property called increasePay<br />
If the object has a property increasePay, you treat it as if it were a function (although this is not checked), and invoke it, and append the result to the string output.text. If it does not have the property increasePay, then you add &#8220;no luck&#8221; to the string output.text instead.</p>
<p>So, the intent of the code (although without checking p to see if it is a Function object, I&#8217;d venture that the code is incomplete), is to check if the objects in the array support the function increasePay. If so, you take further action.</p>
<p>Wouldn&#8217;t it be better to have the objects implement an interface defining increasePay, (e.g. IPayRiseable)? That way you could check:</p>
<p>if(worker[i] is IPayRiseable)<br />
{<br />
   worker[i].increasePay(5);<br />
}</p>
<p>I like your blog, btw.</p>
<p>Cheers.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Keith Peters</title>
		<link>http://flexblog.faratasystems.com/2006/10/09/a-coding-challenge/comment-page-1#comment-36</link>
		<dc:creator>Keith Peters</dc:creator>
		<pubDate>Mon, 09 Oct 2006 14:01:06 +0000</pubDate>
		<guid isPermaLink="false">http://flexblog.faratasystems.com/?p=98#comment-36</guid>
		<description>I understand it. You have an array of objects which may or may not have an &quot;increasePay&quot; method. You want to loop through it and if the object has that method call it and add the result to the text field. If not, add &quot;no luck&quot; to the text field.

As for WHY it&#039;s written the way it is... obfuscation?</description>
		<content:encoded><![CDATA[<p>I understand it. You have an array of objects which may or may not have an &#8220;increasePay&#8221; method. You want to loop through it and if the object has that method call it and add the result to the text field. If not, add &#8220;no luck&#8221; to the text field.</p>
<p>As for WHY it&#8217;s written the way it is&#8230; obfuscation?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mark Piller</title>
		<link>http://flexblog.faratasystems.com/2006/10/09/a-coding-challenge/comment-page-1#comment-34</link>
		<dc:creator>Mark Piller</dc:creator>
		<pubDate>Mon, 09 Oct 2006 13:41:37 +0000</pubDate>
		<guid isPermaLink="false">http://flexblog.faratasystems.com/?p=98#comment-34</guid>
		<description>Although, &quot;polymorphism without interfaces&quot; sounds like a counter-oo concept, here&#039;s an explanation of the code snippet:

You iterate over some instances in the workers array and for each instance get the &quot;increadePay&quot; function reference. If the function is not available for a particular object instance, you append &quot;no luck&quot; to the output field, otherwise, you add whatever increasePay( 5 ) returns.

Mark</description>
		<content:encoded><![CDATA[<p>Although, &#8220;polymorphism without interfaces&#8221; sounds like a counter-oo concept, here&#8217;s an explanation of the code snippet:</p>
<p>You iterate over some instances in the workers array and for each instance get the &#8220;increadePay&#8221; function reference. If the function is not available for a particular object instance, you append &#8220;no luck&#8221; to the output field, otherwise, you add whatever increasePay( 5 ) returns.</p>
<p>Mark</p>
]]></content:encoded>
	</item>
</channel>
</rss>

