Skip to content

Instantly share code, notes, and snippets.

@ivanacostarubio
Created May 22, 2012 21:08
Show Gist options
  • Select an option

  • Save ivanacostarubio/2771631 to your computer and use it in GitHub Desktop.

Select an option

Save ivanacostarubio/2771631 to your computer and use it in GitHub Desktop.
A sample of the Open Close Principle
# THIS
def classrooms_in_same_building
return [] unless building
Classroom.where(:building_id => building.id)
end
#
# THIS VS THAT!
#
# THAT
def classrooms_in_same_building(classroom=Classroom)
return [] unless building
classroom.where(:building_id => building.id)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment