[Borges-users] refactoring

wilkes joiner wilkesjoiner at gmail.com
Sun May 2 21:35:10 EDT 2004


In other languages, I typically put class methods at the top of the
class definition.  For example

Java or C-suck:
class A {
    public static A aFactoryMethod() {}
    public static void ClassLevelSetter {}
    // you get the picture
}

so I really like the class << self thing in Ruby.  It provides a
natural grouping of class methods that makes code easier for me to
read, your mileage may vary.

class A
  class << self
    ## all my class methods
   end
end

By the way, that it is one thing that makes reading the Borges code
difficult.  Methods seemed to be semi-randomly placed through out the
classes.  Is this a result of the smalltalk to ruby translation?  Is
this something that you guys think is worth cleaning up?  This could
just be a perception from lack of familiarity with the code base.

Cheers,
Wilkes

On Sun, 02 May 2004 18:53:45 +0200, Kaspar Schiess <eule at space.ch> wrote:
> 
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
> 
> Слепнев Владимир wrote:
> 
> |> You seem to get bugged by the 'class << self' thing all over the place.
> |> Do you know about this http://www.rubygarden.org/ruby?ClassMethods
> |> discussion ?
> |
> |
> | Why not just create regular class methods (def self.foo...end) when we
> | need them? Why use those singleton hacks? This may sometimes be needed
> | if we want subclasses to behave in a certain way - but it doesn't really
> | apply to Borges, and to me this kind of thing is a "code smell" anyway.
> 
> class A
> ...
> end
> 
> t = A.new
> class << t
>         def hack
>         end
> end
> 
> This is a singleton hack. But
> 
> class A
>         class << self
>                 def someclassmethod
>                 end
>         end
> end
> 
> is none. It's just another way of saying def A.someclassmethod. I kind
> of like the class << self idiom because it should be natural to people
> at ease with the language. And it makes think the rest about it,
> especially because it is well documented (see link posted earlier).
> 
> I don't get the point of this being *code smell*.
> 
> About the properties:
> Yes, they are a third leg, and they must go away. But we will need a
> kind of runtime configuration that is common to all applications that
> can be changed indepently of code, this is needed for deployment (stage,
> test, live, ...). I would appreciate work being done on a configuration
> system that we call could reuse in our own apps, and one that includes
> Borges config. There certainly is a common need for this.
> 
> The fact that they are hot-changeable is nice too, but the admin/seaside
> has to go.
> 
> I am meaning no insult by my remarks about the class << self; however I
> find that to be valid Ruby code. Excuse me if it comes across as one.
> 
> best regards,
> 
> - --
> kaspar
> 
> semantics & semiotics
> code manufacture
> 
> www.tua.ch/ruby
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.2.4 (MingW32)
> Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org
> 
> iD8DBQFAlSeZFifl4CA0ImQRAmZrAJ9KUERFqnoItpGKkjhR5USoaKgiIwCgncNe
> tMm4L0VK9O4ALLOvNbxQTCw=
> =iXmy
> -----END PGP SIGNATURE-----
> 
> 
> --
> Borges-users mailing list
> http://borges.rubyforge.org/ - Borges-users at rubyforge.org
> http://rubyforge.org/mailman/listinfo/borges-users
>



More information about the Borges-users mailing list