/Notes/ Object-oriented design
Notes from reading Sandi Metz’s Practical Object-Oriented Design in Ruby
- Hiding parts of the code to make things appear to be smaller
In a well-designed app, classes that are super complex don’t change very much, & code that changes a lot is pretty simple - sweet spot of OOP!
OOD wants these types of objects:
- OOP is a play where you create living beings and make a world where action happens
- different kinds of objects can respond to same message. Share a common form
- objects strive for independence
- objects are more players of their roles than instances of their type. Substitutable
- factories hide the rules for picking the right player of a role
- ‘I know what I want, you know how to do it.’ They give ignorance
- Decide roles - what is the common thing they do - inject a smarter thing
- Isolate the things you want to vary
- Push conditionals up the stack, back to the first place someone could have had enough info to pick the right object. Factories are where conditionals go.