Catalog

Record Details

Catalog Search



Practical object-oriented design in Ruby : an agile primer / Sandi Metz.

Metz, Sandi. (Author).

Record details

  • ISBN: 0321721330 (alk. paper)
  • Physical Description: xxiii, 247 p. : il. (algunas col.) ; 23 cm.
  • Publisher: Upper Saddle River, NJ : Addison-Wesley, 2013.

Content descriptions

Bibliography, etc. Note:
Incluye bibliografía e índice.
Formatted Contents Note:
Object-oriented design -- Designing classes with a single responsibility -- Managing dependencies -- Creating flexible interfaces -- Reducing costs with duck typing -- Acquiring behavior through inheritance -- Sharing role behavior with modules -- Combining objects with composition -- Designing cost-effective tests.
Subject: Object-oriented programming (Computer science).
Ruby (Computer program language).

Available copies

  • 1 of 1 copy available at IPICYT.

Holds

  • 0 current holds with 1 total copy.
Show Only Available Copies
Location Call Number / Copy Notes Barcode Shelving Location Status Due Date
Biblioteca Ipicyt QA76.64M4 P7 2013 LCI00528 Coleccion General Available -

Forewordxv
Introductionxvii
Acknowledgmentsxxi
About the Authorxxiii
1. Object-Oriented Design1
In Praise of Design2
The Problem Design Solves2
Why Change Is Hard3
A Practical Definition of Design4
The Tools of Design4
Design Principles5
Design Patterns6
The Act of Design7
How Design Fails7
When to Design8
Judging Design10
A Brief Introduction to Object-Oriented Programming11
Procedural Languages12
Object-Oriented Languages12
Summary14
2. Designing Classes with a Single Responsibility15
Deciding What Belongs in a Class16
Grouping Methods into Classes16
Organizing Code to Allow for Easy Changes16
Creating Classes That Have a Single Responsibility17
An Example Application: Bicycles and Gears17
Why Single Responsibility Matters20
Determining If a Class Has a Single Responsibility22
Determining When to Make Design Decisions22
Writing Code That Embraces Change24
Depend on Behavior, Not Data24
Enforce Single Responsibility Everywhere29
Finally, the Real Wheel33
Summary34
3. Managing Dependencies35
Understanding Dependencies36
Recognizing Dependencies37
Coupling Between Objects (CBO)37
Other Dependencies38
Writing Loosely Coupled Code39
Inject Dependencies39
Isolate Dependencies42
Remove Argument-Order Dependencies46
Managing Dependency Direction51
Reversing Dependencies51
Choosing Dependency Direction53
Summary57
4. Creating Flexible Interfaces59
Understanding Interfaces59
Defining Interfaces61
Public Interfaces62
Private Interfaces62
Responsibilities, Dependencies, and Interfaces62
Finding the Public Interface63
An Example Application: Bicycle Touring Company63
Constructing an Intention64
Using Sequence Diagrams65
Asking for "What" Instead of Telling "How"69
Seeking Context Independence71
Trusting Other Objects73
Using Messages to Discover Objects74
Creating a Message-Based Application76
Writing Code That Puts Its Best (Inter)Face Forward76
Create Explicit Interfaces76
Honor the Public Interfaces of Others78
Exercise Caution When Depending on Private Interfaces79
Minimize Context79
The Law of Demeter80
Defining Demeter80
Consequences of Violations80
Avoiding Violations82
Listening to Demeter82
Summary83
5. Reducing Costs with Duck Typing85
Understanding Duck Typing85
Overlooking the Duck87
Compounding the Problem87
Finding the Duck90
Consequences of Duck Typing94
Writing Code That Relies on Ducks95
Recognizing Hidden Ducks96
Placing Trust in Your Ducks98
Documenting Duck Types98
Sharing Code Between Ducks99
Choosing Your Ducks Wisely99
Conquering a Fear of Duck Typing100
Subverting Duck Types with Static Typing100
Static versus Dynamic Typing101
Embracing Dynamic Typing102
Summary104
6. Acquiring Behavior Through Inheritance105
Understanding Classical Inheritance105
Recognizing Where to Use Inheritance106
Starting with a Concrete Class106
Embedding Multiple Types109
Finding the Embedded Types111
Choosing Inheritance112
Drawing Inheritance Relationships114
Misapplying Inheritance114
Finding the Abstraction116
Creating an Abstract Superclass117
Promoting Abstract Behavior120
Separating Abstract from Concrete123
Using the Template Method Pattern125
Implementing Every Template Method127
Managing Coupling Between Superclasses and Subclasses129
Understanding Coupling129
Decoupling Subclasses Using Hook Messages134
Summary139
7. Sharing Role Behavior with Modules141
Understanding Roles142
Finding Roles142
Organizing Responsibilities143
Removing Unnecessary Dependencies145
Writing the Concrete Code147
Extracting the Abstraction150
Looking Up Methods154
Inheriting Role Behavior158
Writing Inheritable Code158
Recognize the Antipatterns158
Insist on the Abstraction159
Honor the Contract159
Use the Template Method Pattern160
Preemptively Decouple Classes161
Create Shallow Hierarchies161
Summary162
8. Combining Objects with Composition163
Composing a Bicycle of Parts164
Updating the Bicycle Class164
Creating a Parts Hierarchy165
Composing the Parts Object168
Creating a Part169
Making the Parts Object More Like an Array172
Manufacturing Parts176
Creating the PartsFactory177
Leveraging the PartsFactory178
The Composed Bicycle180
Deciding Between Inheritance and Composition184
Accepting the Consequences of Inheritance184
Accepting the Consequences of Composition187
Choosing Relationships188
Summary190
9. Designing Cost-Effective Tests191
Intentional Testing192
Knowing Your Intentions193
Knowing What to Test194
Knowing When to Test197
Knowing How to Test198
Testing Incoming Messages200
Deleting Unused Interfaces202
Proving the Public Interface203
Isolating the Object Under Test205
Injecting Dependencies Using Classes207
Injecting Dependencies as Roles208
Testing Private Methods213
Ignoring Private Methods During Tests213
Removing Private Methods from the Class Under Test214
Choosing to Test a Private Method214
Testing Outgoing Messages215
Ignoring Query Messages215
Proving Command Messages216
Testing Duck Types219
Testing Roles219
Using Role Tests to Validate Doubles224
Testing Inherited Code229
Specifying the Inherited Interface229
Specifying Subclass Responsibilities233
Testing Unique Behavior236
Summary240
Afterword241
Index243

Additional Resources