Tell don’t ask
Aug 8, 2017 · 1 min read
Instead of asking the internal state of an object just let it to decide what to do with the message.
Pros:
- The data and the methods are together on the same place.
- It’s easier to change everything because they are together.
- Remove conditionals.
Cons:
- Add additional responsability.
When not to follow this principle:
- Most of the cases adding more responsability to an Active record instance is not a good idea, so this is a case when you don’t want to follow tell don’t ask.
