Design Pattern -- from Java to Ruby Richard E kohe www.ekohe.com Web Development & Graphic Design China Ruby on Rails Development - Rails Consulting - Rails Services - Merb - Offshore Web Development
Why use Design Pattern For reuse www.ekohe.com Web Development & Graphic Design China Ruby on Rails Development - Rails Consulting - Rails Services - Merb - Offshore Web Development
Why use Design Pattern For communication www.ekohe.com Web Development & Graphic Design China Ruby on Rails Development - Rails Consulting - Rails Services - Merb - Offshore Web Development Define a Node interface, all of leaf nodes and internal nodes should implements the interface, internal nodes has a list that includes other internal nodes and leaf nodes and it can add sub-nodes. But leaf node can’t have add sub-node method. Multi-level Menus?
Why use Design Pattern For communication www.ekohe.com Web Development & Graphic Design China Ruby on Rails Development - Rails Consulting - Rails Services - Merb - Offshore Web Development Composite Pattern Multi-level Menus?
Difference from java to ruby Classes are Objects Messages, not function call Duck Typing Mixin www.ekohe.com Web Development & Graphic Design China Ruby on Rails Development - Rails Consulting - Rails Services - Merb - Offshore Web Development
Singleton Pattern ensures a class has only one instance, and provides a global point of access to it www.ekohe.com Web Development & Graphic Design China Ruby on Rails Development - Rails Consulting - Rails Services - Merb - Offshore Web Development
Singleton Pattern www.ekohe.com Web Development & Graphic Design China Ruby on Rails Development - Rails Consulting - Rails Services - Merb - Offshore Web Development You are my only wife You are my only husband
Singleton Pattern -- java Eager loading Lazy loading www.ekohe.com Web Development & Graphic Design China Ruby on Rails Development - Rails Consulting - Rails Services - Merb - Offshore Web Development
Singleton Pattern -- ruby Ruby built-in singleton www.ekohe.com Web Development & Graphic Design China Ruby on Rails Development - Rails Consulting - Rails Services - Merb - Offshore Web Development
www.ekohe.com Web Development & Graphic Design China Ruby on Rails Development - Rails Consulting - Rails Services - Merb - Offshore Web Development
Built-in (Singleton) www.ekohe.com Web Development & Graphic Design China Ruby on Rails Development - Rails Consulting - Rails Services - Merb - Offshore Web Development Ruby for Design Pattern
Observer Pattern defines a one-to-many dependency between objects so that when one object changes state, all of its dependents are notified and updated automatically www.ekohe.com Web Development & Graphic Design China Ruby on Rails Development - Rails Consulting - Rails Services - Merb - Offshore Web Development
Observer Pattern www.ekohe.com Web Development & Graphic Design China Ruby on Rails Development - Rails Consulting - Rails Services - Merb - Offshore Web Development Temperature Detector Subscribe Notify Notify Temprature changed
Observer Pattern -- java www.ekohe.com Web Development & Graphic Design China Ruby on Rails Development - Rails Consulting - Rails Services - Merb - Offshore Web Development
Observer Pattern -- java www.ekohe.com Web Development & Graphic Design China Ruby on Rails Development - Rails Consulting - Rails Services - Merb - Offshore Web Development
Observer Pattern -- java Java built-in observer www.ekohe.com Web Development & Graphic Design China Ruby on Rails Development - Rails Consulting - Rails Services - Merb - Offshore Web Development
Observer Pattern -- ruby Ruby built-in observer www.ekohe.com Web Development & Graphic Design China Ruby on Rails Development - Rails Consulting - Rails Services - Merb - Offshore Web Development
www.ekohe.com Web Development & Graphic Design China Ruby on Rails Development - Rails Consulting - Rails Services - Merb - Offshore Web Development
Built-in (Singleton, Observer ) Mixin www.ekohe.com Web Development & Graphic Design China Ruby on Rails Development - Rails Consulting - Rails Services - Merb - Offshore Web Development Ruby for Design Pattern
Iterator Pattern provides a way to access the elements of an aggregate object sequentially without exposing its underlying representation www.ekohe.com Web Development & Graphic Design China Ruby on Rails Development - Rails Consulting - Rails Services - Merb - Offshore Web Development
Iterator Pattern www.ekohe.com Web Development & Graphic Design China Ruby on Rails Development - Rails Consulting - Rails Services - Merb - Offshore Web Development Count 1 2 3 10
Iterator Pattern -- java www.ekohe.com Web Development & Graphic Design China Ruby on Rails Development - Rails Consulting - Merb - Offshore Web Development External Iterator
Iterator Pattern -- java www.ekohe.com Web Development & Graphic Design China Ruby on Rails Development - Rails Consulting - Merb - Offshore Web Development Internal Iterator
Iterator Pattern -- ruby Internal Iterator .each www.ekohe.com Web Development & Graphic Design China Ruby on Rails Development - Rails Consulting - Rails Services - Merb - Offshore Web Development
Built-in (Singleton, Observer, Iterator ) Mixin www.ekohe.com Web Development & Graphic Design China Ruby on Rails Development - Rails Consulting - Rails Services - Merb - Offshore Web Development Ruby for Design Pattern
returns an instance of one of several possible classes, depending on the data provided to it. www.ekohe.com Web Development & Graphic Design China Ruby on Rails Development - Rails Consulting - Rails Services - Merb - Offshore Web Development Simple Factory Pattern
www.ekohe.com Web Development & Graphic Design China Ruby on Rails Development - Rails Consulting - Rails Services - Merb - Offshore Web Development Simple Factory Pattern
www.ekohe.com Web Development & Graphic Design China Ruby on Rails Development - Rails Consulting - Rails Services - Merb - Offshore Web Development Simple Factory Pattern -- java
www.ekohe.com Web Development & Graphic Design China Ruby on Rails Development - Rails Consulting - Rails Services - Merb - Offshore Web Development Simple Factory Pattern -- java
Classes are Objects www.ekohe.com Web Development & Graphic Design China Ruby on Rails Development - Rails Consulting - Rails Services - Merb - Offshore Web Development Simple Factory Pattern -- ruby
Built-in (Singleton, Observer, Iterator)‏ Mixin Classes are Objects www.ekohe.com Web Development & Graphic Design China Ruby on Rails Development - Rails Consulting - Rails Services - Merb - Offshore Web Development Ruby for Design Pattern
encapsulates a request as an object, thereby letting you parameterize clients with different requests, queue or log requests, and support undoable operations. www.ekohe.com Web Development & Graphic Design China Ruby on Rails Development - Rails Consulting - Rails Services - Merb - Offshore Web Development Command Pattern
www.ekohe.com Web Development & Graphic Design China Ruby on Rails Development - Rails Consulting - Rails Services - Merb - Offshore Web Development Command Pattern Increase temperature command Decrease temperature command
www.ekohe.com Web Development & Graphic Design China Ruby on Rails Development - Rails Consulting - Rails Services - Merb - Offshore Web Development Command Pattern -- java
Proc www.ekohe.com Web Development & Graphic Design China Ruby on Rails Development - Rails Consulting - Rails Services - Merb - Offshore Web Development Command Pattern -- ruby
Built-in (Singleton, Observer, Iterator)‏ Mixin Classes are Objects Proc www.ekohe.com Web Development & Graphic Design China Ruby on Rails Development - Rails Consulting - Rails Services - Merb - Offshore Web Development Ruby for Design Pattern
Make use of ruby advantage www.ekohe.com Web Development & Graphic Design China Ruby on Rails Development - Rails Consulting - Rails Services - Merb - Offshore Web Development Other Design Patterns
Principle DRY – Don't Repeat Yourself Convention Over Configuration www.ekohe.com Web Development & Graphic Design China Ruby on Rails Development - Rails Consulting - Rails Services - Merb - Offshore Web Development
Resources Design Pattern – Elements of Reusable Object-Oriented Software Erich Gamma, Richard Helm, Ralph Johnson, John Vlissides Head First Design Pattern Kathy Sierra, Bert Bates Design Pattern in Ruby Russ Olsen www.ekohe.com Web Development & Graphic Design China Ruby on Rails Development - Rails Consulting - Rails Services - Merb - Offshore Web Development
Q&A happy to discuss and fix my mistakes www.ekohe.com Web Development & Graphic Design China Ruby on Rails Development - Rails Consulting - Rails Services - Merb - Offshore Web Development

Design Pattern From Java To Ruby

  • 1.
    Design Pattern -- from Java to Ruby Richard E kohe www.ekohe.com Web Development & Graphic Design China Ruby on Rails Development - Rails Consulting - Rails Services - Merb - Offshore Web Development
  • 2.
    Why use DesignPattern For reuse www.ekohe.com Web Development & Graphic Design China Ruby on Rails Development - Rails Consulting - Rails Services - Merb - Offshore Web Development
  • 3.
    Why use DesignPattern For communication www.ekohe.com Web Development & Graphic Design China Ruby on Rails Development - Rails Consulting - Rails Services - Merb - Offshore Web Development Define a Node interface, all of leaf nodes and internal nodes should implements the interface, internal nodes has a list that includes other internal nodes and leaf nodes and it can add sub-nodes. But leaf node can’t have add sub-node method. Multi-level Menus?
  • 4.
    Why use DesignPattern For communication www.ekohe.com Web Development & Graphic Design China Ruby on Rails Development - Rails Consulting - Rails Services - Merb - Offshore Web Development Composite Pattern Multi-level Menus?
  • 5.
    Difference from javato ruby Classes are Objects Messages, not function call Duck Typing Mixin www.ekohe.com Web Development & Graphic Design China Ruby on Rails Development - Rails Consulting - Rails Services - Merb - Offshore Web Development
  • 6.
    Singleton Pattern ensuresa class has only one instance, and provides a global point of access to it www.ekohe.com Web Development & Graphic Design China Ruby on Rails Development - Rails Consulting - Rails Services - Merb - Offshore Web Development
  • 7.
    Singleton Pattern www.ekohe.comWeb Development & Graphic Design China Ruby on Rails Development - Rails Consulting - Rails Services - Merb - Offshore Web Development You are my only wife You are my only husband
  • 8.
    Singleton Pattern -- java Eager loading Lazy loading www.ekohe.com Web Development & Graphic Design China Ruby on Rails Development - Rails Consulting - Rails Services - Merb - Offshore Web Development
  • 9.
    Singleton Pattern -- ruby Ruby built-in singleton www.ekohe.com Web Development & Graphic Design China Ruby on Rails Development - Rails Consulting - Rails Services - Merb - Offshore Web Development
  • 10.
    www.ekohe.com Web Development& Graphic Design China Ruby on Rails Development - Rails Consulting - Rails Services - Merb - Offshore Web Development
  • 11.
    Built-in (Singleton) www.ekohe.comWeb Development & Graphic Design China Ruby on Rails Development - Rails Consulting - Rails Services - Merb - Offshore Web Development Ruby for Design Pattern
  • 12.
    Observer Pattern definesa one-to-many dependency between objects so that when one object changes state, all of its dependents are notified and updated automatically www.ekohe.com Web Development & Graphic Design China Ruby on Rails Development - Rails Consulting - Rails Services - Merb - Offshore Web Development
  • 13.
    Observer Pattern www.ekohe.comWeb Development & Graphic Design China Ruby on Rails Development - Rails Consulting - Rails Services - Merb - Offshore Web Development Temperature Detector Subscribe Notify Notify Temprature changed
  • 14.
    Observer Pattern -- java www.ekohe.com Web Development & Graphic Design China Ruby on Rails Development - Rails Consulting - Rails Services - Merb - Offshore Web Development
  • 15.
    Observer Pattern -- java www.ekohe.com Web Development & Graphic Design China Ruby on Rails Development - Rails Consulting - Rails Services - Merb - Offshore Web Development
  • 16.
    Observer Pattern -- java Java built-in observer www.ekohe.com Web Development & Graphic Design China Ruby on Rails Development - Rails Consulting - Rails Services - Merb - Offshore Web Development
  • 17.
    Observer Pattern -- ruby Ruby built-in observer www.ekohe.com Web Development & Graphic Design China Ruby on Rails Development - Rails Consulting - Rails Services - Merb - Offshore Web Development
  • 18.
    www.ekohe.com Web Development& Graphic Design China Ruby on Rails Development - Rails Consulting - Rails Services - Merb - Offshore Web Development
  • 19.
    Built-in (Singleton, Observer ) Mixin www.ekohe.com Web Development & Graphic Design China Ruby on Rails Development - Rails Consulting - Rails Services - Merb - Offshore Web Development Ruby for Design Pattern
  • 20.
    Iterator Pattern providesa way to access the elements of an aggregate object sequentially without exposing its underlying representation www.ekohe.com Web Development & Graphic Design China Ruby on Rails Development - Rails Consulting - Rails Services - Merb - Offshore Web Development
  • 21.
    Iterator Pattern www.ekohe.comWeb Development & Graphic Design China Ruby on Rails Development - Rails Consulting - Rails Services - Merb - Offshore Web Development Count 1 2 3 10
  • 22.
    Iterator Pattern --java www.ekohe.com Web Development & Graphic Design China Ruby on Rails Development - Rails Consulting - Merb - Offshore Web Development External Iterator
  • 23.
    Iterator Pattern --java www.ekohe.com Web Development & Graphic Design China Ruby on Rails Development - Rails Consulting - Merb - Offshore Web Development Internal Iterator
  • 24.
    Iterator Pattern -- ruby Internal Iterator .each www.ekohe.com Web Development & Graphic Design China Ruby on Rails Development - Rails Consulting - Rails Services - Merb - Offshore Web Development
  • 25.
    Built-in (Singleton, Observer, Iterator ) Mixin www.ekohe.com Web Development & Graphic Design China Ruby on Rails Development - Rails Consulting - Rails Services - Merb - Offshore Web Development Ruby for Design Pattern
  • 26.
    returns an instanceof one of several possible classes, depending on the data provided to it. www.ekohe.com Web Development & Graphic Design China Ruby on Rails Development - Rails Consulting - Rails Services - Merb - Offshore Web Development Simple Factory Pattern
  • 27.
    www.ekohe.com Web Development& Graphic Design China Ruby on Rails Development - Rails Consulting - Rails Services - Merb - Offshore Web Development Simple Factory Pattern
  • 28.
    www.ekohe.com Web Development& Graphic Design China Ruby on Rails Development - Rails Consulting - Rails Services - Merb - Offshore Web Development Simple Factory Pattern -- java
  • 29.
    www.ekohe.com Web Development& Graphic Design China Ruby on Rails Development - Rails Consulting - Rails Services - Merb - Offshore Web Development Simple Factory Pattern -- java
  • 30.
    Classes are Objectswww.ekohe.com Web Development & Graphic Design China Ruby on Rails Development - Rails Consulting - Rails Services - Merb - Offshore Web Development Simple Factory Pattern -- ruby
  • 31.
    Built-in (Singleton, Observer,Iterator)‏ Mixin Classes are Objects www.ekohe.com Web Development & Graphic Design China Ruby on Rails Development - Rails Consulting - Rails Services - Merb - Offshore Web Development Ruby for Design Pattern
  • 32.
    encapsulates a requestas an object, thereby letting you parameterize clients with different requests, queue or log requests, and support undoable operations. www.ekohe.com Web Development & Graphic Design China Ruby on Rails Development - Rails Consulting - Rails Services - Merb - Offshore Web Development Command Pattern
  • 33.
    www.ekohe.com Web Development& Graphic Design China Ruby on Rails Development - Rails Consulting - Rails Services - Merb - Offshore Web Development Command Pattern Increase temperature command Decrease temperature command
  • 34.
    www.ekohe.com Web Development& Graphic Design China Ruby on Rails Development - Rails Consulting - Rails Services - Merb - Offshore Web Development Command Pattern -- java
  • 35.
    Proc www.ekohe.com WebDevelopment & Graphic Design China Ruby on Rails Development - Rails Consulting - Rails Services - Merb - Offshore Web Development Command Pattern -- ruby
  • 36.
    Built-in (Singleton, Observer,Iterator)‏ Mixin Classes are Objects Proc www.ekohe.com Web Development & Graphic Design China Ruby on Rails Development - Rails Consulting - Rails Services - Merb - Offshore Web Development Ruby for Design Pattern
  • 37.
    Make use ofruby advantage www.ekohe.com Web Development & Graphic Design China Ruby on Rails Development - Rails Consulting - Rails Services - Merb - Offshore Web Development Other Design Patterns
  • 38.
    Principle DRY –Don't Repeat Yourself Convention Over Configuration www.ekohe.com Web Development & Graphic Design China Ruby on Rails Development - Rails Consulting - Rails Services - Merb - Offshore Web Development
  • 39.
    Resources Design Pattern– Elements of Reusable Object-Oriented Software Erich Gamma, Richard Helm, Ralph Johnson, John Vlissides Head First Design Pattern Kathy Sierra, Bert Bates Design Pattern in Ruby Russ Olsen www.ekohe.com Web Development & Graphic Design China Ruby on Rails Development - Rails Consulting - Rails Services - Merb - Offshore Web Development
  • 40.
    Q&A happy todiscuss and fix my mistakes www.ekohe.com Web Development & Graphic Design China Ruby on Rails Development - Rails Consulting - Rails Services - Merb - Offshore Web Development