From: Rick DeNatale Date: 2006-09-06T04:34:40+09:00 Subject: Re: Best way to do helpers for a constructor On 9/5/06, Jason Merrill wrote: > What is the best practice for creating helper methods for a > constructor? In Java (not that I know that much about Java), my > instinct would be to make helper methods for a constructor be private > class methods, since they generally don't rely on the state of the > object being created. In Ruby, however, it seems you're not allowed > to call private class methods from within instance methods. But unlike Java, Ruby doesn't have constructors, instead it has class methods new and allocate which are rarely overidden. The standard new method calls allocate to get storage for the instance and then 'sends' initialize to the instance, using a non-standard mechanism. So I'd just make the helper methods private instance methods. Since initialize itself is an instance methods it will work. There's nothing written in stone saying that an instance method should rely on instance state. IMHO this difference between Java and Ruby is a good thing. Ruby doesn't have "tyrannical constructors" as Martin Fowler put in his article on Rake. -- Rick DeNatale My blog on Ruby http://talklikeaduck.denhaven2.com/