Skip to content

Instantly share code, notes, and snippets.

@SriMaddy
Last active August 29, 2015 14:19
Show Gist options
  • Save SriMaddy/4888702be2e1cece7be4 to your computer and use it in GitHub Desktop.
Save SriMaddy/4888702be2e1cece7be4 to your computer and use it in GitHub Desktop.
Practical OOD in Ruby : Addison - Wesley
Recognize Dependency :
-> A class has another class
-> calls method in another class
-> Args that message(method) requires. Gear knows Wheel.new
requires rim and tire as well as order of Args.
More coupling -> More dependency
Tightly coupled two objects act as single entity
Avoid message chaining on different objects
If you cannot remove dependency from class just isolate them.
Use wrapping method to isolate external dependency.
Dependency have direction : By reversing direction of dependency code can be optimized.
_________________________________________________
| Abstract Zone | Danger Zone | /|\ Dependency More
|______________________|________________________| |
| Neutral Zone | Neutral Zone | |
|______________________|________________________| | Dependency Less
Change less Change more
-------------------------------------------------->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment