Skip to content

Instantly share code, notes, and snippets.

@nfedyashev
Forked from nicholasjhenry/gist:1110289
Created October 18, 2011 07:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nfedyashev/1294822 to your computer and use it in GitHub Desktop.
Save nfedyashev/1294822 to your computer and use it in GitHub Desktop.
Sandi Metz - Less - The Path to Better Design
# Sandi Metz - Less - The Path to Better Design
# http://vimeo.com/26330100
# http://less-goruco.heroku.com/
#
# Abstractions are more stable than concretions.
class Trip
attr_reader :bicycles, :customers, :vehicle
def prepare(preparers)
preparers.each {|preparer| preparer.prepare_trip(self)}
end
end
class Mechanic
def prepare_trip(trip)
trip.bicycles.each {|bicycle| prepare_bicycle(bicycle)}
end
end
class TripCoordinator
def prepare_trip(trip)
buy_food(trip.customers)
end
end
class Driver
def prepare_trip(trip)
vehicle = trip.vehicle
gas_up(vehicle)
fill_water_tank(vehicle)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment