On Wed, Mar 13, 2013 at 6:18 PM, Joel Pearson <lists / ruby-forum.com> wrote:
> Robert Klemme wrote in post #1101459:

>> I always find constructs like this suspicious:
>>
>> def cell( row, col )
>>   Element.new( self, indices_to_address( row, col ) )
>> end
>>
>> The purpose of a constructor is to construct something and return it
>> so the caller can do something with it.  If you do not do that
>> everybody is left wondering what happens to the newly created
>> instance.  If you need it only temporary then another method name
>> would be better.  Or change it so that not Element stores itself
>> somewhere in "self" but rather "self" itself.
>
> I'm not really sure what you mean by this. My intention is that cell and
> cells are like alises for range, but you can select by 1-based indices
> (again, copying excel). Range is also capable of referring to more than
> 1 cell, and can take cells as arguments. This allow for purely numerical
> selection of any area, I've allowed columns to be selected numerically
> as well.

It's about the constructor (Element.new) - not addressing methods.
Bottom line: don't abuse constructors for doing algorithmic things.
Constructors are for constructing something so it is in a consistent
state and can be worked with. Placing the complete logic in a
constructor will prevent flexible use of classes.

Cheers

robert


-- 
remember.guy do |as, often| as.you_can - without end
http://blog.rubybestpractices.com/