Practical Object-Oriented Design in Ruby: An Agile Primer / Edition 1

Paperback (Print)
Used and New from Other Sellers
Used and New from Other Sellers
from $25.70
Usually ships in 1-2 business days
(Save 35%)
Other sellers (Paperback)
  • All (10) from $25.70   
  • New (7) from $25.70   
  • Used (3) from $28.24   

Overview

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
Read More Show Less

Editorial Reviews

From the Publisher

“This is great stuff! Your descriptions are so vibrant and vivid that I’m rediscovering the truth buried in OO principles that are otherwise so internalized that I forget to explore them. Your thoughts on design and knowing the future are especially eloquent.”

—Ian McFarland, President, New Context, Inc.

“As a self-taught programmer, this was an extremely helpful dive into some OOP concepts that I could definitely stand to become better acquainted with! And, I’m not alone: there’s a sign posted at work that reads, ‘WWSMD? – What Would Sandi Metz Do?’”

—Jonathan Mukai, Pivotal in NYC

“Meticulously pragmatic and exquisitely articulate, Practical Object Oriented Design in Ruby makes otherwise elusive knowledge available to an audience which desperately needs it. The prescriptions are appropriate both as rules for novices and as guidelines for experienced professionals.”

—Katrina Owen, developer, Bengler

“I do believe this will be the most important Ruby book of 2012. Not only is the book 100% on-point, Sandi has an easy writing style with lots of great analogies that drive every point home.”

—Avdi Grimm, Author of Exceptional Ruby and Objects on Rails

“While Ruby is an object-oriented language, little time is spent in the documentation on what OO truly means or how it should direct the way we build programs. Here Metz brings it to the fore, covering most of the key principles of OO development and design in an engaging, easy-to-understand manner. This is a must for any respectable Ruby bookshelf.”

–Peter Cooper, editor, Ruby Weekly

“So good, I couldn’t put it down! This is a must-read for anyone wanting to do object-oriented programming in any language, not to mention it has completely changed the way I approach testing.”

–Charles Max Wood, video and audio show host, TeachMeToCode.com

“Distilling scary OO design practices with clear-cut examples and explanations makes this a book or novices and experts alike. It is well worth the study by anyone interested in OO design being done right and ‘light.’ I thoroughly enjoyed this book.”

–Manuel Pais, editor, InfoQ.com

“If you call yourself a Ruby programmer, you should read this book. It’s jam-packed with great nuggets of practical advice and coding techniques that you can start applying immediately in your projects.”

–Ylan Segal, San Diego Ruby User Group

“This is the best OO book I’ve ever read. It’s short, sweet, but potent. It slowly moves from simple techniques to more advanced, each example improving on the last. The ideas it presents are useful not just in Ruby but in static languages like C# too. Highly recommended!”

–Kevin Berridge, software engineering manager, Pointe Blank Solutions, and organizer, Burning River Developers Meetup

“The book is just perfect! The elegance of Ruby shines but it also works as an A to Z of object-oriented programming in general.”

–Emil Rondahl, C# & .NET consultant

“This is an exceptional Ruby book, in which Metz offers a practical look at writing maintainable, clean, idiomatic code in Ruby. Absolutely fantastic, recommended for my Ruby hacker friends.”

–Zachary “Zee” Spencer, freelancer & coach

“This is the best programming book I’ve read in ages. Sandi talks about basic principles, but these are things we’re probably still doing wrong and she shows us why and how. The book has the perfect mix of code, diagrams, and words. I can’t recommend it enough and if you’re serious about being a better programmer, you’ll read it and agree.

–Derick Hitchcock, senior developer, SciMed Solutions

“I predict this will become a classic. I have an uncomfortable familiarity with programming literature, and this book is on a completely different level. I am astonished when I find a book that offers new insights and ideas, and even more surprised when it can do so, not just once, but throughout the pages. This book is excellently written, well-organized, with lucid explanations of technical programming concepts.”

–Han S. Kang, software engineer and member of the LA Rubyists

“You should read this book if you write software for a living. The future developers who inherit your code will thank you.”

–Jose Fernandez, senior software engineer at New Relic

“Metz’s take on the subject is rooted strongly in theory, but the explanation always stays grounded in real world concerns, which helped me to internalize it. The book is clear and concise, yet achieves a tone that is more friendly than terse.”

–Alex Strasheim, network administrator, Ensemble Travel Group

“This is an amazing book about just how to do object-oriented thinking when you’re programming in Ruby. Although there are some chapters that are more Ruby-specific, this book could be a great resource for developers in any language. All in all, I can’t recommend this book enough.”

–James Hwang, thriceprime.com

“Whether you’re just getting started in your software development career, or you’ve been coding for years (like I have), it’s likely that you’ll learn a lot from Ms. Metz’s book. She does a fantastic job of explaining the whys of well-designed software along with the hows.”

–Gabe Hollombe, software craftsman, avantbard.com

“In short, this is in my top five programming books I’ve ever read. I believe that in twenty years this will be considered one of the definitive works on object-oriented programming. I plan to re-read it at least once a year to keep my skills from falling into atrophy. If you’re a relatively new, intermediate, or even somewhat advanced OO developer in any language, purchasing this book is the best way I know to level up your OO design skills.”

–Brandon Hays, freelance software developer

Read More Show Less

Product Details

  • ISBN-13: 9780321721334
  • Publisher: Addison-Wesley
  • Publication date: 9/28/2012
  • Series: Addison-Wesley Professional Ruby Series
  • Edition description: New Edition
  • Edition number: 1
  • Pages: 272
  • Sales rank: 150,220
  • Product dimensions: 6.90 (w) x 9.00 (h) x 0.60 (d)

Meet the Author

Sandi Metz has thirty years of experience working on projects that survived to grow and change. She now writes code every day as a software architect at Duke University, where her team solves real problems for customers who have large object-oriented applications that have been evolving for more than fifteen years. She has spoken at Ruby Nation and speaks regularly at the Gotham Ruby Users Conference.
Read More Show Less

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

Read More Show Less

Customer Reviews

Be the first to write a review
( 0 )
Rating Distribution

5 Star

(0)

4 Star

(0)

3 Star

(0)

2 Star

(0)

1 Star

(0)

Your Rating:

Your Name: Create a Pen Name or

Barnes & Noble.com Review Rules

Our reader reviews allow you to share your comments on titles you liked, or didn't, with others. By submitting an online review, you are representing to Barnes & Noble.com that all information contained in your review is original and accurate in all respects, and that the submission of such content by you and the posting of such content by Barnes & Noble.com does not and will not violate the rights of any third party. Please follow the rules below to help ensure that your review can be posted.

Reviews by Our Customers Under the Age of 13

We highly value and respect everyone's opinion concerning the titles we offer. However, we cannot allow persons under the age of 13 to have accounts at BN.com or to post customer reviews. Please see our Terms of Use for more details.

What to exclude from your review:

Please do not write about reviews, commentary, or information posted on the product page. If you see any errors in the information on the product page, please send us an email.

Reviews should not contain any of the following:

  • - HTML tags, profanity, obscenities, vulgarities, or comments that defame anyone
  • - Time-sensitive information such as tour dates, signings, lectures, etc.
  • - Single-word reviews. Other people will read your review to discover why you liked or didn't like the title. Be descriptive.
  • - Comments focusing on the author or that may ruin the ending for others
  • - Phone numbers, addresses, URLs
  • - Pricing and availability information or alternative ordering information
  • - Advertisements or commercial solicitation

Reminder:

  • - By submitting a review, you grant to Barnes & Noble.com and its sublicensees the royalty-free, perpetual, irrevocable right and license to use the review in accordance with the Barnes & Noble.com Terms of Use.
  • - Barnes & Noble.com reserves the right not to post any review -- particularly those that do not follow the terms and conditions of these Rules. Barnes & Noble.com also reserves the right to remove any review at any time without notice.
  • - See Terms of Use for other conditions and disclaimers.
Search for Products You'd Like to Recommend

Recommend other products that relate to your review. Just search for them below and share!

Create a Pen Name

Your Pen Name is your unique identity on BN.com. It will appear on the reviews you write and other website activities. Your Pen Name cannot be edited, changed or deleted once submitted.

 
Your Pen Name can be any combination of alphanumeric characters (plus - and _), and must be at least two characters long.

Continue Anonymously
Sort by: Showing all of 3 Customer Reviews
  • Anonymous

    Posted December 7, 2013

    No text was provided for this review.

    No text was provided for this review.

    Was this review helpful? Yes  No   Report this review
  • Anonymous

    Posted March 19, 2013

    No text was provided for this review.

  • Anonymous

    Posted April 30, 2013

    No text was provided for this review.

Sort by: Showing all of 3 Customer Reviews

If you find inappropriate content, please report it to Barnes & Noble
Why is this product inappropriate?
Comments (optional)