- 30 October 2016
- Patterns Design
- Ruby - Factory Method pattern
Hi there. Today we will discover Dependency Injection (DI). To understand all benefits of dependency injection we should understand why dependencies are bad.
Recently I wrote about template pattern. Today I would like to talk about another useful pattern - decorator.
Today I would like to show by simple example how to use template pattern in Ruby.
I'm sure you will find many ways of using that pattern in your application.
There is a great principle in object-oriented programming which says: "Tell, Don't Ask".
This principle tells that we should not ask object about their state, make decision and only then tell them what to do. Rather we should send commands.
There is a good quote about that: