In my last article I introduced this series and here's the first pattern: the Abstract FactoryRead more »
Articles about Design Patterns
The title says it all, but how does one actually implement object oriented design patterns in Ruby? If you're like me and always struggled with putting what you read about programming into an actual implementation and the examples in the book or around the internet weren't enough to quell your doubts, read on.Read more »
Today I want to talk about a pattern that can be very useful when we need to control the flow of a set of events of our objects: The State Pattern a.k.a Finite State Machine.
As a developer it is common to see objects changing their state. At the beginning managing the state of an object can be as simple as having some boolean attributes where you can check if the object is in state A or B. But when the complexity increases you can end up with a number of states that are difficult to manage without breaking the SOLID principles. That is where we can implement the elegant solution provided by the State Pattern.Read more »
In our last article of the refactoring series we saw how design patterns can be used to make our Ruby code beautiful and clean. Design patterns are a powerful tool for any developer and a familiarity with them will lead to better code by forcing a consideration of SOLID principles.
Now let's talk about other pattern that when properly used can be very helpful: The Template Method.Read more »