Created
January 27, 2009 09:53
-
-
Save mattwynne/53262 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # | |
| # 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