Skip to content

Instantly share code, notes, and snippets.

@nicholasjhenry
Created July 27, 2011 20:26
Show Gist options
  • Save nicholasjhenry/1110289 to your computer and use it in GitHub Desktop.
Save nicholasjhenry/1110289 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
@nfedyashev
Copy link

Thanks for sharing!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment