On Tue, Jul 10, 2012 at 12:43 PM, John Lee <[email protected]> wrote:

> Dear Ruby programmers,
>
> Well explained. But what good will it do to make a class method? Compare
> to a instance method.
>
>
The answer to that question depends entirely on your (or your project's)
needs.

Will code that uses the Drawing class be working with an instance most of
the time? If so, your factory method perhaps should very well be an
instance method:

  # code that uses an instance of the Drawing class named @drawing
  # ...
  c = @drawing.give_me_a_circle

However, that may not make sense for your project or you may not have or
generally be working with an instance of the Drawing class. In this case,
the current technique may make the most sense:

  # ...
  c = Drawing.give_me_a_circle

So, the answer is "it depends".

-- 
Kendall Gifford
[email protected]

-- You received this message because you are subscribed to the Google Groups 
ruby-talk-google group. To post to this group, send email to 
[email protected]. To unsubscribe from this group, send email 
to [email protected]. For more options, visit this 
group at https://groups.google.com/d/forum/ruby-talk-google?hl=en

Reply via email to