Tutorial by Examples

Ruby Standard Library has a Singleton module which implements the Singleton pattern. The first step in creating a Singleton class is to require and include the Singleton module in a class: require 'singleton' class Logger include Singleton end If you try to instantiate this class as you n...
The observer pattern is a software design pattern in which an object (called subject) maintains a list of its dependents (called observers), and notifies them automatically of any state changes, usually by calling one of their methods. Ruby provides a simple mechanism to implement the Observer desi...
Decorator pattern adds behavior to objects without affecting other objects of the same class. The decorator pattern is a useful alternative to creating sub-classes. Create a module for each decorator. This approach is more flexible than inheritance because you can mix and match responsibilities in ...
Proxy object is often used to ensure guarded access to another object, which internal business logic we don't want to pollute with safety requirements. Suppose we'd like to guarantee that only user of specific permissions can access resource. Proxy definition: (it ensure that only users which actu...

Page 1 of 1