# Module boundaries and classes within them (Was: Re: Placement of require() and missing symbols)

**URL:** <https://www.ruby-forum.com/t/module-boundaries-and-classes-within-them-was-re-placement-of-require-and-missing-symbols/190273>\
**Category:** Ruby\
**Created:** [June 17, 2010, 4:22pm UTC](https://www.ruby-forum.com/t/module-boundaries-and-classes-within-them-was-re-placement-of-require-and-missing-symbols/190273 "2010-06-17T16:22:35Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Eric\_MSP\_Veith](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/ecd19e/32.png) [@Eric\_MSP\_Veith](https://www.ruby-forum.com/u/Eric_MSP_Veith)\
**Post date:** [June 17, 2010, 4:22pm UTC](https://www.ruby-forum.com/t/module-boundaries-and-classes-within-them-was-re-placement-of-require-and-missing-symbols/190273/1 "2010-06-17T16:22:35Z")

</div>

-----BEGIN PGP SIGNED MESSAGE-----  
Hash: SHA1

Kirk,

On Tuesday 15 June 2010, Kirk H. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) 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:🅰:B \< Foo::A

# …

end

- —\>%—

First question: Is Foo:🅰: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-----
