Skip to content

Instantly share code, notes, and snippets.

@rarous
Forked from steida/gist:1584972
Created January 13, 2012 05:01
Show Gist options
  • Save rarous/1604755 to your computer and use it in GitHub Desktop.
Save rarous/1604755 to your computer and use it in GitHub Desktop.
# Dependency injetion example.
class House
# We are asking for things in contructor.
constructor: (@kitchen) ->
# Service locator antipattern example.
class House
constructor: ->
# our class is looking for kitchen
@kitchen = new Kitchen
# another point of view
# house is frozen
class House
constructor: ->
@kitchen = new Kitchen
# now house can have any kitchen
class House
constructor: (@kitchen) ->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment