Refactoring in Ruby

Paperback (Print)
Used and New from Other Sellers
Used and New from Other Sellers
from $21.01
Usually ships in 1-2 business days
(Save 53%)
Other sellers (Paperback)
  • All (2) from $21.01   
  • Used (2) from $21.01   
Sort by
Page 1 of 1
Showing All
Note: Marketplace items are not eligible for any coupons and promotions
Seller since 2007

Feedback rating:



New — never opened or used in original packaging.

Like New — packaging may have been opened. A "Like New" item is suitable to give as a gift.

Very Good — may have minor signs of wear on packaging but item works perfectly and has no damage.

Good — item is in good condition but packaging may have signs of shelf wear/aging or torn packaging. All specific defects should be noted in the Comments section associated with each item.

Acceptable — item is in working order but may show signs of wear such as scratches or torn packaging. All specific defects should be noted in the Comments section associated with each item.

Used — An item that has been opened and may show signs of wear. All specific defects should be noted in the Comments section associated with each item.

Refurbished — A used item that has been renewed or updated and verified to be in proper working condition. Not necessarily completed by the original manufacturer.

Very Good
2009 Paperback Very good

Ships from: San Jose, CA

Usually ships in 1-2 business days

  • Canadian
  • International
  • Standard, 48 States
  • Standard (AK, HI)
  • Express, 48 States
  • Express (AK, HI)
Seller since 2014

Feedback rating:


Condition: Good
2009 Paperback Good Connecting readers with great books since 1972. Used books may not include companion materials, some shelf wear, may contain highlighting/notes, and may not ... include cd-rom or access codes. Customer service is our top priority! Read more Show Less

Ships from: Fremont, CA

Usually ships in 1-2 business days

  • Standard, 48 States
  • Standard (AK, HI)
  • Express, 48 States
  • Express (AK, HI)
Page 1 of 1
Showing All
Sort by


The First Hands-On, Practical, All-Ruby Refactoring Workbook!

Refactoring–the art of improving the design of existing code–has taken the world by storm. So has Ruby. Now, for the first time, there’s a refactoring workbook designed from the ground up for the dynamic Ruby language.

Refactoring in Ruby gives you all the realistic, hands-on practice you need to refactor Ruby code quickly and effectively. You’ll discover how to recognize “code smells,” which signal opportunities for improvement, and then perfect your program’s design one small, safe step at a time.

The book shows you when and how to refactor with both legacy code and during new test-driven development, and walks you through real-world refactoring in detail. The workbook concludes with several applications designed to help practice refactoring in realistic domains, plus a handy code review checklist you’ll refer to again and again. Along the way, you’ll learn powerful lessons about designing higher quality Ruby software–lessons that will enable you to experience the joy of writing consistently great code.

Refactoring in Ruby will help you

  • Recognize why poor code design occurs, so you can prevent it from occurring in your own code
  • Master better design techniques that lead to more efficient, reliable, and maintainable software
  • Fix code that’s too long, large, or difficult to follow
  • Ferret out duplication, and express each idea “once and only once”
  • Recognize missing or inadequately formed classes
  • Simplify overly complex relationships between classes and their subclasses
  • Achieve the right balance of responsibilities among objects
  • Make your code easier to test and change
  • Cope with incomplete library modules, and fix runaway dependencies
  • Learn the next steps to take after you refactor
Read More Show Less

Product Details

  • ISBN-13: 9780321545046
  • Publisher: Addison-Wesley
  • Publication date: 10/30/2009
  • Pages: 288
  • Product dimensions: 6.90 (w) x 9.00 (h) x 0.70 (d)

Meet the Author

William C. Wake is a senior consultant with Industrial Logic, Inc. From 2007 to early 2009, he managed development at Gene Codes Forensics, Inc., a producer of bioinformatics software. From 2001 through 2006, he was an independent consultant focused on agile software. He’s the author of the Refactoring Workbook (Addison-Wesley, 2004) and coauthor of Design Patterns in Java (Addison-Wesley, 2006). His web site is

Kevin Rutherford, Ph.D., is an independent agile and TDD coach based in the United Kingdom. He has worked in software development for more than 25 years, and since 1997 has been coaching organizations to become highly responsive service providers. He founded the U.K.’s AgileNorth group and is regularly involved on the agile conference circuit. His working practices focus on use of the Theory of Constraints and code quality, and he is the author of the Reek tool for Ruby. His web site is

Read More Show Less

Table of Contents

Foreword xvii

Preface xix

About the Authors xxiii

Part I: The Art of Refactoring 1

Chapter 1: A Refactoring Example 3

Sparkline Script 3

Consistency 6

Testability 8

Greedy Methods 8

Greedy Module 9

Comments 10

Whole Objects 11

Feature Envy 12

Uncommunicative Names 14

Derived Values 15

Wabi-Sabi 17

Summing Up 18

What’s Next 18

Chapter 2: The Refactoring Cycle 19

What Is Refactoring? 19

Smells Are Problems 20

The Refactoring Cycle 21

When Are We Done? 21

Test-Driven/Behavior-Driven Development 22

Exercise 23

What’s Next 23

Chapter 3: Refactoring Step by Step 25

The Refactoring Environment 25

Inside a Refactoring 26

The Generic Refactoring Micro-Process 30

Exercises 33

What’s Next 33

Chapter 4: Refactoring Practice 35

Read Other Books 35

Practice Refactoring 35

Exercises to Try 36

Participate in the Community 37

Exercise 38

What’s Next 38

Part II: Code Smells 39

Chapter 5: Measurable Smells 41

Comments 42

Long Method 44

Large Module 46

Long Parameter List 48

Exercises 49

Chapter 6: Names 57

Type Embedded in Name 59

Uncommunicative Name 60

Inconsistent Names 61

Exercises 62

Chapter 7: Unnecessary Complexity 65

Dead Code 66

Speculative Generality 68

Greedy Method 70

Procedural Code 72

Dynamic Code Creation 74

Exercises 76

Chapter 8: Duplication 79

Derived Value 80

Repeated Value 81

Duplicated Code 83

Alternative Modules with Different Interfaces 85

Exercises 86

Chapter 9: Conditional Logic 93

Nil Check 94

Special Case 96

Complicated Boolean Expression 98

Control Coupling 100

Simulated Polymorphism 101

Exercises 103

Chapter 10: Data 107

Open Secret 108

Data Class 110

Data Clump 112

Temporary Field 114

Exercises 115

Chapter 11: Inheritance 125

Implementation Inheritance 126

Refused Bequest 128

Inappropriate Intimacy (Subclass Form) 130

Lazy Class 131

Exercises 133

Chapter 12: Responsibility 135

Feature Envy 136

Utility Function 138

Global Variable 140

Inappropriate Intimacy (General Form) 141

Message Chain 143

Middle Man 145

Greedy Module 146

Exercises 148

Chapter 13: Accommodating Change 153

Divergent Change 154

Shotgun Surgery 156

Parallel Inheritance Hierarchies 158

Combinatorial Explosion 159

Exercises 160

Chapter 14: Libraries 163

Incomplete Library Module 164

Reinvented Wheel 166

Runaway Dependencies 167

Exercises 168

Part III: Programs to Refactor 171

Chapter 15: A Simple Game 173

Code 173

Refactoring 175

Development Episodes 180

Chapter 16: Time Recording 183

Preparing the Soil 187

Substitute Algorithm 191

Optional Extras 194

Chapter 17: Calculator 197

Code 198

Refactoring 209

Thank You 211

Part IV: Appendices 213

Appendix A: Answers to Selected Questions 215

The Refactoring Cycle 215

Refactoring Step by Step 216

Refactoring Practice 216

Measurable Smells 217

Names 220

Unnecessary Complexity 222

Duplication 225

Conditional Logic 230

Data 233

Inheritance 237

Responsibility 239

Accommodating Change 241

Libraries 244

A Simple Game 246

Time Recording 247

Appendix B: Ruby Refactoring Tools 251

Code Smell Detectors 251

Environments with Refactoring Support 252

Bibliography 253

Index 255

Read More Show Less

Customer Reviews

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

5 Star


4 Star


3 Star


2 Star


1 Star


Your Rating:

Your Name: Create a Pen Name or

Barnes & 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 & 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 & 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 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


  • - By submitting a review, you grant to Barnes & and its sublicensees the royalty-free, perpetual, irrevocable right and license to use the review in accordance with the Barnes & Terms of Use.
  • - Barnes & reserves the right not to post any review -- particularly those that do not follow the terms and conditions of these Rules. Barnes & 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 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
  • Anonymous

    Posted January 1, 2010

    No text was provided for this review.

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