Best Ruby and OOP Lesson I've seen
Sandi Metz at RailsConf 2015 - Nothing is Something
You must see this video, I transcribed the summary here in order to remember it. But, it make perfect sense after seen the conference.
Summary:
-
If you’re talking to nil, it’s something. Use the Null Object Pattern. Don’t check for nil.
-
Ware Inheritance, it’s not for sharing behaviour. There’s no such thing as one specialization. You must Isolate the thing that varies. Name the concept. Define the role. And them Inject the players.
-
Belive in Nothing. I don’t want to write a condition, I want to send a message to an Object. It seems like nothing, but Nothing it’s always Something.