Ruby Design Pattern 2

  1. 1. Composite pattern
  2. 2. iterator pattern
  3. 3. decorator pattern
  4. 4. “Design Pattern in Ruby” 读后感

Composite pattern

The GoF called the design pattern for our “the sum acts like one of the parts” situation the Composite pattern.

iterator pattern

very common in normal programming languages.(Enum)

decorator pattern

the most famous usage in ruby is alias_method_chain. There is a very interesting passage about alias_method_chain in “metaprogramming-ruby-2”

The Rise and Fall of alias_method_chain

“Design Pattern in Ruby” 读后感

以前经常去啃一些gem的源代码。比如omniauth,比如warden甚至Rack。没看设计模式之前总是觉得云里雾里,读了设计模式才觉得其实是自己还没有入门。
觉得自己很了不起的时候,还是静下来多读书吧。

如果你觉得本文对你有帮助,请给我点赞助。