Home > Store > Programming > Ruby

larger cover

Add To My Wish List

Register your product to gain access to bonus material or receive a coupon.

Practical Object-Oriented Design in Ruby: An Agile Primer

Best Value Purchase

Book + eBook Bundle

  • Your Price: $43.19
  • List Price: $71.98
  • Includes EPUB, MOBI, and PDF
  • About eBook Formats
  • This eBook includes the following formats, accessible from your Account page after purchase:

    ePub EPUB The open industry format known for its reflowable content and usability on supported mobile devices.

    MOBI MOBI The eBook format compatible with the Amazon Kindle and Amazon Kindle applications.

    Adobe Reader PDF The popular standard, used most often with the free Adobe® Reader® software.

    This eBook requires no passwords or activation to read. We customize your eBook by discretely watermarking it with your name, making it uniquely yours.

Individual Purchases

Book

  • Your Price: $31.99
  • List Price: $39.99
  • Usually ships in 24 hours.

eBook (Watermarked)

  • Your Price: $25.59
  • List Price: $31.99
  • Includes EPUB, MOBI, and PDF
  • About eBook Formats
  • This eBook includes the following formats, accessible from your Account page after purchase:

    ePub EPUB The open industry format known for its reflowable content and usability on supported mobile devices.

    MOBI MOBI The eBook format compatible with the Amazon Kindle and Amazon Kindle applications.

    Adobe Reader PDF The popular standard, used most often with the free Adobe® Reader® software.

    This eBook requires no passwords or activation to read. We customize your eBook by discretely watermarking it with your name, making it uniquely yours.

  • Description
  • Extras
  • Sample Content
  • Updates
  • Copyright 2013
  • Dimensions: 7" x 9-1/8"
  • Pages: 272
  • Edition: 1st
  • Book
  • ISBN-10: 0-321-72133-0
  • ISBN-13: 978-0-321-72133-4

The Complete Guide to Writing More Maintainable, Manageable, Pleasing, and Powerful Ruby Applications

 

Ruby’s widely admired ease of use has a downside: Too many Ruby and Rails applications have been created without concern for their long-term maintenance or evolution. The Web is awash in Ruby code that is now virtually impossible to change or extend. This text helps you solve that problem by using powerful real-world object-oriented design techniques, which it thoroughly explains using simple and practical Ruby examples.

 

Sandi Metz has distilled a lifetime of conversations and presentations about object-oriented design into a set of Ruby-focused practices for crafting manageable, extensible, and pleasing code. She shows you how to build new applications that can survive success and repair existing applications that have become impossible to change. Each technique is illustrated with extended examples, all downloadable from the companion Web site, poodr.info.

 

The first title to focus squarely on object-oriented Ruby application design, Practical Object-Oriented Design in Ruby will guide you to superior outcomes, whatever your previous Ruby experience. Novice Ruby programmers will find specific rules to live by; intermediate Ruby programmers will find valuable principles they can flexibly interpret and apply; and advanced Ruby programmers will find a common language they can use to lead development and guide their colleagues.

 

This guide will help you

  • Understand how object-oriented programming can help you craft Ruby code that is easier to maintain and upgrade
  • Decide what belongs in a single Ruby class
  • Avoid entangling objects that should be kept separate
  • Define flexible interfaces among objects
  • Reduce programming overhead costs with duck typing
  • Successfully apply inheritance
  • Build objects via composition
  • Design cost-effective tests
  • Solve common problems associated with poorly designed Ruby code

 

Related Article

My Life in Tech: Q&A with Software Architect Sandi Metz

Author's Site

Author suggested site: sandimetz.com

Online Sample Chapter

Practical Object-Oriented Design in Ruby: Managing Dependencies

Sample Pages

Download the sample pages (includes Chapter 3 and Index)

Table of Contents

Foreword         xv

Introduction         xvii

Acknowledgments         xxi

About the Author         xxiii

 

Chapter 1: Object-Oriented Design         1

In Praise of Design   2

The Tools of Design   4

The Act of Design   7

A Brief Introduction to Object-Oriented Programming   11

Summary 14

 

Chapter 2: Designing Classes with a Single Responsibility         15

Deciding What Belongs in a Class   16

Grouping Methods into Classes   16

Organizing Code to Allow for Easy Changes   16

Creating Classes That Have a Single Responsibility   17

Writing Code That Embraces Change   24

Finally, the Real Wheel   33

Summary   34

 

Chapter 3: Managing Dependencies         35

Understanding Dependencies   36

Writing Loosely Coupled Code   39

Managing Dependency Direction   51

Summary   57

 

Chapter 4: Creating Flexible Interfaces         59

Understanding Interfaces   59

Defining Interfaces   61

Public Interfaces   62

Private Interfaces   62

Responsibilities, Dependencies, and Interfaces   62

Finding the Public Interface   63

Writing Code That Puts Its Best (Inter)Face Forward   76

The Law of Demeter   80

Summary   83

 

Chapter 5: Reducing Costs with Duck Typing         85

Understanding Duck Typing   85

Writing Code That Relies on Ducks   95

Conquering a Fear of Duck Typing   100

Summary   104

 

Chapter 6: Acquiring Behavior Through Inheritance         105

Understanding Classical Inheritance   105

Recognizing Where to Use Inheritance   106

Misapplying Inheritance   114

Finding the Abstraction   116

Managing Coupling Between Superclasses and Subclasses   129

Summary 139

 

Chapter 7: Sharing Role Behavior with Modules         141

Understanding Roles   142

Writing Inheritable Code   158

Summary   162

 

Chapter 8: Combining Objects with Composition         163

Composing a Bicycle of Parts   164

Composing the Parts Object   168

Manufacturing Parts   176

The Composed Bicycle   180

Deciding Between Inheritance and Composition   184

Summary   190

 

Chapter 9: Designing Cost-Effective Tests         191

Intentional Testing   192

Testing Incoming Messages   200

Testing Private Methods   213

Testing Outgoing Messages   215

Testing Duck Types   219

Testing Inherited Code   229

Summary 240

 

Afterword         241

 

Index          243

 

FREE

ONE MONTH ACCESS!

WITH PURCHASE


Get unlimited 30-day access to thousands of Books & Training Videos about technology, professional development and digital media If you continue your subscription after your 30-day trial, you can receive 30% off a monthly subscription to the Safari Library for up to 12 months.