- Your class can be no longer than a hundred lines of code.
- Your methods can be no longer than five lines of code
- You can pass no more than four parameters and you can't just make it one big hash.
- In your controller, you can only instantiate one object, to do whatever it is that needs to be done.
- Your view can only know about one instance variable.
- Your Rails view should only send messages to that object i.e., no Demeter violations.[ "thunder dome principal". Translated: one model in, one model out! ]
- Rules are meant to be broken if by breaking them you produce better code. [ ...where "better code" is validated by explaining why you want to break the rule to someone else. ]
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
# This is used for debugging callbacks chains, to use this code: | |
# 1. Drop this into an initializer in your rails app | |
# 2. Set the LG_FILE_PATH to the file location you want the logging to go too | |
# 3. Set MODEL_TO_DEBUG to the class you want to debug, ie: MODEL_TO_DEBUG | |
# 4. Change the print_string method to save the relevant information. It has | |
# access to any instance methods on the object presently in the callback chain | |
# Note: Not sure how compatible this is with other versions of rails/state-machine | |
# VERSIONS PATCHED | |
# State-Machine 1.1.2 |