<?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: What happened to constructor parameters?</title>
	<atom:link href="http://www.rubenswieringa.com/blog/what-happened-to-constructor-parameters/feed" rel="self" type="application/rss+xml" />
	<link>http://www.rubenswieringa.com/blog/what-happened-to-constructor-parameters</link>
	<description>Ruben writes flashy writings</description>
	<pubDate>Thu, 28 Aug 2008 10:12:41 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.5.1</generator>
		<item>
		<title>By: Ruben</title>
		<link>http://www.rubenswieringa.com/blog/what-happened-to-constructor-parameters#comment-1360</link>
		<dc:creator>Ruben</dc:creator>
		<pubDate>Wed, 25 Jul 2007 15:14:21 +0000</pubDate>
		<guid isPermaLink="false">http://www.rubenswieringa.com/blog/what-happened-to-constructor-parameters#comment-1360</guid>
		<description>&lt;strong&gt;@Tink:&lt;/strong&gt; Good point! I think that a good example of what you said about read-only properties is the &lt;a href="http://livedocs.adobe.com/flex/201/langref/flash/events/Event.html#Event()" rel="nofollow"&gt;Event contructor&lt;/a&gt;, where you can set the &lt;em&gt;bubbles&lt;/em&gt; and &lt;em&gt;cancelable&lt;/em&gt; properties that need to be read-only after that..

However I do not think that contructor-parameters make code less readable per se.
Take for instance the &lt;a href="http://livedocs.adobe.com/flex/201/langref/flash/geom/Point.html" rel="nofollow"&gt;Point&lt;/a&gt; class, it only has one other property of its own, so when I'm reading &lt;em&gt;"new Point(110, 351)"&lt;/em&gt; it's pretty obvious that it's being assigned a coordinate.
This is in my opinion much more preferable than writing 3 lines of code just to set a coordinate..

So if this is the case for normal &lt;abbr&gt;AS3&lt;/abbr&gt; code, why not for classes in the Flex framework? I mean, just because those classes will be used mostly through MXML (where contructors cannot be used), doesn't mean I will never add an instance of it through Actionscript (&lt;em&gt;.addChild()&lt;/em&gt; ), does it?

&lt;strong&gt;@Neil:&lt;/strong&gt; Perhaps Adobe did decide not to use constructor-parameters for the sake of consistency, I don't think it makes the point less valid though..</description>
		<content:encoded><![CDATA[<p><strong>@Tink:</strong> Good point! I think that a good example of what you said about read-only properties is the <a href="http://livedocs.adobe.com/flex/201/langref/flash/events/Event.html#Event()" rel="nofollow">Event contructor</a>, where you can set the <em>bubbles</em> and <em>cancelable</em> properties that need to be read-only after that..</p>
<p>However I do not think that contructor-parameters make code less readable per se.<br />
Take for instance the <a href="http://livedocs.adobe.com/flex/201/langref/flash/geom/Point.html" rel="nofollow">Point</a> class, it only has one other property of its own, so when I&#8217;m reading <em>&#8220;new Point(110, 351)&#8221;</em> it&#8217;s pretty obvious that it&#8217;s being assigned a coordinate.<br />
This is in my opinion much more preferable than writing 3 lines of code just to set a coordinate..</p>
<p>So if this is the case for normal <abbr>AS3</abbr> code, why not for classes in the Flex framework? I mean, just because those classes will be used mostly through MXML (where contructors cannot be used), doesn&#8217;t mean I will never add an instance of it through Actionscript (<em>.addChild()</em> ), does it?</p>
<p><strong>@Neil:</strong> Perhaps Adobe did decide not to use constructor-parameters for the sake of consistency, I don&#8217;t think it makes the point less valid though..</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: nwebb</title>
		<link>http://www.rubenswieringa.com/blog/what-happened-to-constructor-parameters#comment-1359</link>
		<dc:creator>nwebb</dc:creator>
		<pubDate>Wed, 25 Jul 2007 14:59:13 +0000</pubDate>
		<guid isPermaLink="false">http://www.rubenswieringa.com/blog/what-happened-to-constructor-parameters#comment-1359</guid>
		<description>As Eric pointed out, a lot of properties can't be set that early on. MXML components don't have a constructor, and so maybe they don't pass args in to AS3 classes for the sake of consistency (even when those properties *could* be set in the constructor)?</description>
		<content:encoded><![CDATA[<p>As Eric pointed out, a lot of properties can&#8217;t be set that early on. MXML components don&#8217;t have a constructor, and so maybe they don&#8217;t pass args in to AS3 classes for the sake of consistency (even when those properties *could* be set in the constructor)?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Tink</title>
		<link>http://www.rubenswieringa.com/blog/what-happened-to-constructor-parameters#comment-1348</link>
		<dc:creator>Tink</dc:creator>
		<pubDate>Wed, 25 Jul 2007 00:32:26 +0000</pubDate>
		<guid isPermaLink="false">http://www.rubenswieringa.com/blog/what-happened-to-constructor-parameters#comment-1348</guid>
		<description>There is no harm in using constructor parameters but IMO it isn't as readable.

i.e this following uses constructor parameters. It passing 2 parameters but it isn't immediately possible to see what those parameters are for.

---------------------------------------------------
var myComponent:MyComponent = new MyComponent( 400, 300 );
---------------------------------------------------

compared to the following where you can clearly see the 2 setters are for width and height. If the object has a well written API this is readable at a glance.

---------------------------------------------------
var myComponent:MyComponent = new MyComponent();
myComponent.width = 400;
myComponent.height = 300;
---------------------------------------------------

It makes sense to use (or you don't have much choice) constructor params when the object requires those properties to be set when they are created, such as a BitmapData that requires a width, height and transparency property. These properties are then read only.</description>
		<content:encoded><![CDATA[<p>There is no harm in using constructor parameters but IMO it isn&#8217;t as readable.</p>
<p>i.e this following uses constructor parameters. It passing 2 parameters but it isn&#8217;t immediately possible to see what those parameters are for.</p>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<br />
var myComponent:MyComponent = new MyComponent( 400, 300 );<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;</p>
<p>compared to the following where you can clearly see the 2 setters are for width and height. If the object has a well written API this is readable at a glance.</p>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<br />
var myComponent:MyComponent = new MyComponent();<br />
myComponent.width = 400;<br />
myComponent.height = 300;<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;</p>
<p>It makes sense to use (or you don&#8217;t have much choice) constructor params when the object requires those properties to be set when they are created, such as a BitmapData that requires a width, height and transparency property. These properties are then read only.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ruben</title>
		<link>http://www.rubenswieringa.com/blog/what-happened-to-constructor-parameters#comment-58</link>
		<dc:creator>Ruben</dc:creator>
		<pubDate>Wed, 28 Mar 2007 17:25:08 +0000</pubDate>
		<guid isPermaLink="false">http://www.rubenswieringa.com/blog/what-happened-to-constructor-parameters#comment-58</guid>
		<description>Yeah, I guess that's a good point you're making there. Though I still think that some properties (such as width and height) might look good as constructor parameters, even if it would mean a few more lines inside of the component-classes themselves; it's all about the degree to which something is easy in usage, right?
That aside, I don't really think Adobe's going to go through the hassle of changing component signiatures merely in order to make this slight improvement, do you?</description>
		<content:encoded><![CDATA[<p>Yeah, I guess that&#8217;s a good point you&#8217;re making there. Though I still think that some properties (such as width and height) might look good as constructor parameters, even if it would mean a few more lines inside of the component-classes themselves; it&#8217;s all about the degree to which something is easy in usage, right?<br />
That aside, I don&#8217;t really think Adobe&#8217;s going to go through the hassle of changing component signiatures merely in order to make this slight improvement, do you?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Eric Cancil</title>
		<link>http://www.rubenswieringa.com/blog/what-happened-to-constructor-parameters#comment-57</link>
		<dc:creator>Eric Cancil</dc:creator>
		<pubDate>Wed, 28 Mar 2007 14:22:36 +0000</pubDate>
		<guid isPermaLink="false">http://www.rubenswieringa.com/blog/what-happened-to-constructor-parameters#comment-57</guid>
		<description>I think one of the big reasons behind this is the event cycle.  A lot of properties simply cannot be set in the constructor, and would have to wait until the creation complete event to be set.  Thus, you would have to set it once in the constructor...basically pending it til a time you could set it again, on creation complete.  That and the lack of access to a constructor in mxml.</description>
		<content:encoded><![CDATA[<p>I think one of the big reasons behind this is the event cycle.  A lot of properties simply cannot be set in the constructor, and would have to wait until the creation complete event to be set.  Thus, you would have to set it once in the constructor&#8230;basically pending it til a time you could set it again, on creation complete.  That and the lack of access to a constructor in mxml.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
