Skip to content

Instantly share code, notes, and snippets.

@mattwynne
Created January 27, 2009 09:53
Show Gist options
  • Select an option

  • Save mattwynne/53262 to your computer and use it in GitHub Desktop.

Select an option

Save mattwynne/53262 to your computer and use it in GitHub Desktop.
#
# Here is a (simplistic) example of a class with, arguably, too many responsibilites.
# Methods are clustered together in the file to maintain a semblance of cohesion, but there is no enapsulation of these
# behaviours. A class like this will grow ugly and over-complex.
#
# Forcing yourself to order the methods alphabetically would be one way to alert you to these multiple responsibilities,
# because you would feel uncomfortable breaking up the cohesive clusters of methods in order to sort them by this
# arbitrary rule.
#
class BloatedUser
# Password stuff
def change_password(old_password, new_password)
end
def verify_password(password)
end
def send_password_reminder
end
# Roles stuff
def member_of?(role)
end
def join_role(role)
end
def remove_from_role(role)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment