Prev: [ANN] unicorn 1.0.0 - yes, this is a real project
Next: method interface - hash argument vs. named parameters
From: Eric MSP Veith on 17 Jun 2010 10:09 -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Kirk, On Tuesday 15 June 2010, Kirk Haines <wyhaines(a)gmail.com> wrote: > The best practice is to put it where it makes sense to put it, bearing > in mind you might have to read your code again in two years, or > someone else might have to read your code. > [...] > If you move your requires, I'd put them outside of the class bodies > and method bodies, but as close to the relevant code as is reasonable. thanks for your answer. I've been digging into the RDBI sources to satisfy my curiosity and found it the way you described. The RDBI sources brought up another question for me, which I append here because it seems loosely related. Consider this code: - ---%<--- # a.rb: module Foo class A # ... end end # a/b.rb: require 'a' class Foo::A::B < Foo::A # ... end - --->%--- First question: Is Foo::A::B part of the "Foo" module and the Foo namespace? The latter I guess it's true, but with the first one I'm not sure and I have no idea how to check. Plus, what difference does it make for a class to reside within a module or outside? I know that modules are useful as mixins, which also means one defines a set of methods without them beloning to a particular class. But for a complete class to be part of a module, does that make sense? I.e., can one mixin a class into another? Thanks alot in advance for any insight. Eric -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.9 (GNU/Linux) iEYEARECAAYFAkwaLJkACgkQhS0drJ3goJK8swCeKCwHTodLWKIluwHF8CY9nJ7Z 2nUAn0di3CE+l+rWMKYJGasS1ZbsQiNl =AmQZ -----END PGP SIGNATURE----- |