目次

Practical Object-Oriented Design in Ruby

5 14 21 24 30 59 65 71 81 88 92 105 110 125 141

オブジェクト指向なデザインの本。要するにRubyでの再利用性、耐変更性を考慮した正しい書き方。 デザインパターンの本だと思っていたが、違う。

1. Object-Oriented Design

2. Designing Classes with a Single Responsibility

3. Managing Dependencies

4. Creating Flexible Interfaces

5. Reducing Costs with Duck Typing

class Trip
  def prepare(prepares)
    prepares.each {|preparer|
      preparer.prepare_trip(self)}
  end
end
  
class Mechanic
  def prepare_trip(trip)
    trip.bicycles.each {|bycycle|
      prepare_bicycle(bicycle)}
    end
end

6. Acquiring Behavior Through Inheritance

7. Sharing Role Behavior with Modules

8. Combining Objects with Composition

9. Designing Cost-Effective Tests