From: Kendall Gifford Date: 2012-07-11T04:26:58+09:00 Subject: Re: basic queries --14dae9340e05b1a89304c47eb66e Content-Type: text/plain; charset=UTF-8 On Tue, Jul 10, 2012 at 12:43 PM, John Lee 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 zettabyte@gmail.com --14dae9340e05b1a89304c47eb66e Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
On Tue, Jul 10, 2012 at 12:43 PM, John Lee <= lists@ruby-forum.com> wrote:


The answer to that question depends entirely on your (or your = project's) needs.

Will code that uses the Drawing class be worki= ng with an instance most of the time? If so, your factory method perhaps sh= ould very well be an instance method:

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

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

=C2=A0 # ...
=C2=A0 c =3D Drawing.give_me_a_circle

So, the an= swer is "it depends".

--
Kendall Gifford=
zettabyte@gmail.com
--14dae9340e05b1a89304c47eb66e--