وبلاگ بلیان

Practical Object-Oriented Design: An Agile Primer Using Ruby (2nd Edition)

معرفی کتاب «Practical Object-Oriented Design: An Agile Primer Using Ruby (2nd Edition)» نوشتهٔ Metz, Sandi، منتشرشده توسط نشر Addison-Wesley Professional در سال 2018. این کتاب در فرمت pdf، زبان انگلیسی ارائه شده است. «Practical Object-Oriented Design: An Agile Primer Using Ruby (2nd Edition)» در دستهٔ بدون دسته‌بندی قرار دارد.

Ruby's widely admired simplicity 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, thoroughly explained via simple and practical Ruby examples. Sandi Metz has distilled a lifetime of conversations and presentations about object-oriented design into a proven set of Ruby-focused practices for crafting manageable, extensible, and pleasing code. She demonstrates 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. Fully updated for Ruby 2.X, this guide shows how to: 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 Whatever your previous Ruby experience, Practical Object-Oriented Design in Ruby, Second Edition will guide you to the superior outcomes you're looking for. Cover 1 Half Title 4 Title Page 6 Copyright Page 7 Dedication 8 Contents 10 Introduction 16 Acknowledgments 20 About the Author 22 1 Object-Oriented Design 24 1.1 In Praise of Design 25 1.1.1 The Problem Design Solves 25 1.1.2 Why Change Is Hard 26 1.1.3 A Practical Definition of Design 26 1.2 The Tools of Design 27 1.2.1 Design Principles 27 1.2.2 Design Patterns 29 1.3 The Act of Design 29 1.3.1 How Design Fails 29 1.3.2 When to Design 30 1.3.3 Judging Design 32 1.4 A Brief Introduction to Object-Oriented Programming 33 1.4.1 Procedural Languages 34 1.4.2 Object-Oriented Languages 34 1.5 Summary 36 2 Designing Classes with a Single Responsibility 38 2.1 Deciding What Belongs in a Class 39 2.1.1 Grouping Methods into Classes 39 2.1.2 Organizing Code to Allow for Easy Changes 39 2.2 Creating Classes That Have a Single Responsibility 40 2.2.1 An Example Application: Bicycles and Gears 40 2.2.2 Why Single Responsibility Matters 44 2.2.3 Determining If a Class Has a Single Responsibility 45 2.2.4 Determining When to Make Design Decisions 45 2.3 Writing Code That Embraces Change 47 2.3.1 Depend on Behavior, Not Data 47 2.3.2 Enforce Single Responsibility Everywhere 52 2.4 Finally, the Real Wheel 56 2.5 Summary 58 3 Managing Dependencies 60 3.1 Understanding Dependencies 61 3.1.1 Recognizing Dependencies 62 3.1.2 Coupling Between Objects (CBO) 62 3.1.3 Other Dependencies 63 3.2 Writing Loosely Coupled Code 64 3.2.1 Inject Dependencies 64 3.2.2 Isolate Dependencies 67 3.2.3 Remove Argument-Order Dependencies 71 3.3 Managing Dependency Direction 76 3.3.1 Reversing Dependencies 76 3.3.2 Choosing Dependency Direction 78 3.4 Summary 82 4 Creating Flexible Interfaces 84 4.1 Understanding Interfaces 84 4.2 Defining Interfaces 86 4.2.1 Public Interfaces 87 4.2.2 Private Interfaces 87 4.2.3 Responsibilities, Dependencies, and Interfaces 87 4.3 Finding the Public Interface 88 4.3.1 An Example Application: Bicycle Touring Company 88 4.3.2 Constructing an Intention 88 4.3.3 Using Sequence Diagrams 89 4.3.4 Asking for “What” Instead of Telling “How” 93 4.3.5 Seeking Context Independence 95 4.3.6 Trusting Other Objects 97 4.3.7 Using Messages to Discover Objects 98 4.3.8 Creating a Message-Based Application 100 4.4 Writing Code That Puts Its Best (Inter)Face Forward 100 4.4.1 Create Explicit Interfaces 100 4.4.2 Honor the Public Interfaces of Others 102 4.4.3 Exercise Caution When Depending on Private Interfaces 103 4.4.4 Minimize Context 103 4.5 The Law of Demeter 103 4.5.1 Defining Demeter 104 4.5.2 Consequences of Violations 104 4.5.3 Avoiding Violations 105 4.5.4 Listening to Demeter 106 4.6 Summary 107 5 Reducing Costs with Duck Typing 108 5.1 Understanding Duck Typing 108 5.1.1 Overlooking the Duck 109 5.1.2 Compounding the Problem 111 5.1.3 Finding the Duck 113 5.1.4 Consequences of Duck Typing 117 5.2 Writing Code That Relies on Ducks 118 5.2.1 Recognizing Hidden Ducks 118 5.2.2 Placing Trust in Your Ducks 120 5.2.3 Documenting Duck Types 121 5.2.4 Sharing Code between Ducks 121 5.2.5 Choosing Your Ducks Wisely 121 5.3 Conquering a Fear of Duck Typing 123 5.3.1 Subverting Duck Types with Static Typing 123 5.3.2 Static versus Dynamic Typing 124 5.3.3 Embracing Dynamic Typing 125 5.4 Summary 126 6 Acquiring Behavior through Inheritance 128 6.1 Understanding Classical Inheritance 128 6.2 Recognizing Where to Use Inheritance 129 6.2.1 Starting with a Concrete Class 130 6.2.2 Embedding Multiple Types 132 6.2.3 Finding the Embedded Types 134 6.2.4 Choosing Inheritance 135 6.2.5 Drawing Inheritance Relationships 137 6.3 Misapplying Inheritance 137 6.4 Finding the Abstraction 139 6.4.1 Creating an Abstract Superclass 140 6.4.2 Promoting Abstract Behavior 143 6.4.3 Separating Abstract from Concrete 146 6.4.4 Using the Template Method Pattern 148 6.4.5 Implementing Every Template Method 150 6.5 Managing Coupling between Superclasses and Subclasses 152 6.5.1 Understanding Coupling 152 6.5.2 Decoupling Subclasses Using Hook Messages 157 6.6 Summary 162 7 Sharing Role Behavior with Modules 164 7.1 Understanding Roles 165 7.1.1 Finding Roles 165 7.1.2 Organizing Responsibilities 166 7.1.3 Removing Unnecessary Dependencies 169 7.1.4 Writing the Concrete Code 170 7.1.5 Extracting the Abstraction 173 7.1.6 Looking Up Methods 176 7.1.7 Inheriting Role Behavior 180 7.2 Writing Inheritable Code 181 7.2.1 Recognize the Antipatterns 181 7.2.2 Insist on the Abstraction 181 7.2.3 Honor the Contract 182 7.2.4 Use the Template Method Pattern 183 7.2.5 Preemptively Decouple Classes 183 7.2.6 Create Shallow Hierarchies 183 7.3 Summary 184 8 Combining Objects with Composition 186 8.1 Composing a Bicycle of Parts 186 8.1.1 Updating the Bicycle Class 187 8.1.2 Creating a Parts Hierarchy 188 8.2 Composing the Parts Object 191 8.2.1 Creating a Part 191 8.2.2 Making the Parts Object More Like an Array 195 8.3 Manufacturing Parts 199 8.3.1 Creating the PartsFactory 200 8.3.2 Leveraging the PartsFactory 202 8.4 The Composed Bicycle 204 8.5 Deciding between Inheritance and Composition 208 8.5.1 Accepting the Consequences of Inheritance 209 8.5.2 Accepting the Consequences of Composition 211 8.5.3 Choosing Relationships 212 8.6 Summary 214 9 Designing Cost-Effective Tests 216 9.1 Intentional Testing 217 9.1.1 Knowing Your Intentions 217 9.1.2 Knowing What to Test 219 9.1.3 Knowing When to Test 222 9.1.4 Knowing How to Test 223 9.2 Testing Incoming Messages 225 9.2.1 Deleting Unused Interfaces 227 9.2.2 Proving the Public Interface 227 9.2.3 Isolating the Object under Test 229 9.2.4 Injecting Dependencies Using Classes 231 9.2.5 Injecting Dependencies as Roles 233 9.3 Testing Private Methods 238 9.3.1 Ignoring Private Methods during Tests 239 9.3.2 Removing Private Methods from the Class under Test 239 9.3.3 Choosing to Test a Private Method 239 9.4 Testing Outgoing Messages 240 9.4.1 Ignoring Query Messages 240 9.4.2 Proving Command Messages 241 9.5 Testing Duck Types 244 9.5.1 Testing Roles 244 9.5.2 Using Role Tests to Validate Doubles 250 9.6 Testing Inherited Code 256 9.6.1 Specifying the Inherited Interface 256 9.6.2 Specifying Subclass Responsibilities 259 9.6.3 Testing Unique Behavior 263 9.7 Summary 267 Afterword 268 Index 270 A 270 B 270 C 270 D 272 E 273 F 273 G 273 H 273 I 273 J 274 K 274 L 274 M 274 N 275 O 275 P 275 Q 275 R 275 S 276 T 277 U 277 V 277 W 277 The Complete Guide to Writing Maintainable, Manageable, Pleasing, and Powerful Object-Oriented Applications Object-oriented programming languages have a point of view about how best to model the world. They exist to help you create beautiful, straightforward applications that are easy to change and simple to extend. Unfortunately, the world is awash with object-oriented (OO) applications that are difficult to understand and expensive to change. Even though they're written in OO languages, these applications fail to achieve the promise of OO because their code doesn't reflect the right mindset. The purpose of Practical Object-Oriented Design, Second Edition, is to solve that problem by immersing you in an OO mindset. It teaches powerful, real-world, object-oriented design techniques using simple and practical examples. It will change the way you think about code. Sandi Metz has distilled a lifetime of conversations and presentations about object-oriented design into a proven set of OO practices for crafting manageable, extensible, and pleasing code. She demonstrates how to build new applications that can "survive success" and how to repair those that have become impossible to change. Each technique is illustrated with extended examples in the easy-to-understand Ruby programming language, all downloadable from the companion website, poodr.com . Fully updated for Ruby 2.5, this guide shows how to: Decide what belongs in a single 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 object-oriented code Whatever your previous object-oriented experience, this concise guide will help you achieve the superior outcomes you're looking for The Complete Guide to Writing Maintainable, Manageable, Pleasing, and Powerful Object-Oriented Applications Object-oriented programming languages exist to help you create beautiful, straightforward applications that are easy to change and simple to extend. Unfortunately, the world is awash with object-oriented (OO) applications that are difficult to understand and expensive to change. Practical Object-Oriented Design, Second Edition, immerses you in an OO mindset and teaches you powerful, real-world, object-oriented design techniques with simple and practical examples. Sandi Metz demonstrates 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 in the easy-to-understand Ruby programming language, all downloadable from the companion website, poodr.com. Fully updated for Ruby 2.5, this guide shows how to Decide what belongs in a single 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 Whatever your previous object-oriented experience, this concise guide will help you achieve the superior outcomes you're looking for. Register your book for convenient access to downloads, updates, and/or corrections as they become available. See inside book for details. 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. Sandi Metz. Includes Index.
دانلود کتاب Practical Object-Oriented Design: An Agile Primer Using Ruby (2nd Edition)