Last active
December 16, 2015 04:59
-
-
Save vpivo/5381182 to your computer and use it in GitHub Desktop.
Notes from Practical Object Oriented Design in Ruby
This file contains 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
*Objects have their own behavior. | |
*Objects interact with each other via methods. | |
*Objects should know as little about each other as possible. | |
*Create objects with room for change. | |
*You can not fully design software before writing it. | |
Designing classes with a single responsibilty. | |
*Classes should have a single responsibilty. | |
*Nouns make good classes. | |
*Try to descibe a class in one sentence, without using and. | |
*Make sure code is transparent and readable. | |
*Wrap instance variables in accessor methods so you can depend on behavior, not data. | |
*Methods are free, give them single responsibities so code can be changed easily. | |
*If you have behavior that doesn't quite fit the current class, but doesn't quite need it's own class, isolate it for changes | |
can easily be made later. | |
Managing dependencies. | |
*Keep dependencies light. | |
*Don't overly chain messages. | |
*Use variable to hold objects within other objects. ex. on page 41 | |
*Isolate instance creation, maybe in an instance variable or with a method using condtional assignment. | |
*Isolate external messages. | |
*Use hashes for initialize. ex. on page 47 | |
*Use a defaults method to initialize variables.This can also be removed from initialize. ex. on page 49 | |
*Use a module to instantiate a new object with the arguments, this is a factory method. | |
*Think about which classes are more likely to change and consider their dependents. | |
* |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment