<?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: Constructors in Ruby are not guaranteed to be called</title>
	<atom:link href="http://www.3hv.co.uk/blog/2009/06/03/constructors-in-ruby-are-not-guaranteed-to-be-called/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.3hv.co.uk/blog/2009/06/03/constructors-in-ruby-are-not-guaranteed-to-be-called/</link>
	<description>beautiful code for elegant web sites</description>
	<lastBuildDate>Mon, 23 Nov 2009 16:19:58 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.6</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: 3hv &#187; Blog Archive &#187; Default values in your models</title>
		<link>http://www.3hv.co.uk/blog/2009/06/03/constructors-in-ruby-are-not-guaranteed-to-be-called/comment-page-1/#comment-1396</link>
		<dc:creator>3hv &#187; Blog Archive &#187; Default values in your models</dc:creator>
		<pubDate>Fri, 05 Jun 2009 16:46:05 +0000</pubDate>
		<guid isPermaLink="false">http://www.3hv.co.uk/blog/?p=557#comment-1396</guid>
		<description>[...] default value code into your initialize method, it turns out that, under certain circumstances, it may not be called. Instead, move it to [...]</description>
		<content:encoded><![CDATA[<p>[...] default value code into your initialize method, it turns out that, under certain circumstances, it may not be called. Instead, move it to [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Rahoul Baruah</title>
		<link>http://www.3hv.co.uk/blog/2009/06/03/constructors-in-ruby-are-not-guaranteed-to-be-called/comment-page-1/#comment-1392</link>
		<dc:creator>Rahoul Baruah</dc:creator>
		<pubDate>Thu, 04 Jun 2009 09:22:48 +0000</pubDate>
		<guid isPermaLink="false">http://www.3hv.co.uk/blog/?p=557#comment-1392</guid>
		<description>It looks to me like #allocate is for situations where an object&#039;s state is about to be specified by some other means (such as when deserialising from an external source) - so whatever happens in #initialise would be overridden.  

Which kind of makes sense, as far as ActiveRecord is concerned, IF you hold that an ActiveRecord model is merely a thin wrapper around the state in the database.  

Unfortunately, because we also use ActiveRecord models as a holder for business logic (which may require _temporary_ state) the assumption that all a model&#039;s state is in the database is invalid.  Another flaw in the &quot;mixing-business-logic-and-persistence&quot; model that ActiveRecord follows.</description>
		<content:encoded><![CDATA[<p>It looks to me like #allocate is for situations where an object&#8217;s state is about to be specified by some other means (such as when deserialising from an external source) &#8211; so whatever happens in #initialise would be overridden.  </p>
<p>Which kind of makes sense, as far as ActiveRecord is concerned, IF you hold that an ActiveRecord model is merely a thin wrapper around the state in the database.  </p>
<p>Unfortunately, because we also use ActiveRecord models as a holder for business logic (which may require _temporary_ state) the assumption that all a model&#8217;s state is in the database is invalid.  Another flaw in the &#8220;mixing-business-logic-and-persistence&#8221; model that ActiveRecord follows.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Paul Horsfall</title>
		<link>http://www.3hv.co.uk/blog/2009/06/03/constructors-in-ruby-are-not-guaranteed-to-be-called/comment-page-1/#comment-1391</link>
		<dc:creator>Paul Horsfall</dc:creator>
		<pubDate>Wed, 03 Jun 2009 22:46:53 +0000</pubDate>
		<guid isPermaLink="false">http://www.3hv.co.uk/blog/?p=557#comment-1391</guid>
		<description>I was aware of, or at the very least not surprised by this. And for whatever reason, I don&#039;t think I&#039;ve ever thought of Ruby&#039;s initialize as a constructor. If you were to override YourClass.new and not call super you&#039;d see something similar I suppose, although you wouldn&#039;t get a new instance either in that case would you?

It would be interesting to know why ActiveRecord calls allocate directly though, it seems as though you&#039;d only do so if you specifically wanted an uninitialised instance, but maybe that&#039;s the point.</description>
		<content:encoded><![CDATA[<p>I was aware of, or at the very least not surprised by this. And for whatever reason, I don&#8217;t think I&#8217;ve ever thought of Ruby&#8217;s initialize as a constructor. If you were to override YourClass.new and not call super you&#8217;d see something similar I suppose, although you wouldn&#8217;t get a new instance either in that case would you?</p>
<p>It would be interesting to know why ActiveRecord calls allocate directly though, it seems as though you&#8217;d only do so if you specifically wanted an uninitialised instance, but maybe that&#8217;s the point.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
