O'Reilly logo

Sams Teach Yourself Ruby in 21 Days by Mark Slagell

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Designing Modules and Classes for Clarity and Reuse

When writing a program in Ruby, you organize your code into classes and modules. As we've seen, your efforts have to mesh with certain constraints in the way Ruby organizes and finds code at the class or module level and also at the disk file level.

But even in cases where it's going to be self-evident what to call the files and where to put them, you still have to make decisions about class and module hierarchies. A lot of that decision making has to do with deciding what should be a class and what should be a module.

Classes and modules are very closely related. In almost any case you could, if you felt like it, cut methods from a class, paste them into a module, and then mix the module into ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required