DEV Community

Discussion on: Prefer Ruby Class Method or Mix-In Instance Method?

Collapse
 
briankephart profile image
Brian Kephart

I would prefer the first, because calling Foo.foo clearly shows the receiver of the method, and I know that bar is probably defined in foo.rb.

In the second example, it's less clear where bar is defined. Ok, it's clear in your example, but in a situation where the names aren't so simple, bar might be defined in the current class, or bar.rb, or any other module that's mixed into the current class, or all three.