Your SlideShare is downloading. ×
0
Design Pattern   -- from Java to Ruby <ul><ul><li>Richard </li></ul></ul><ul><ul><li>E kohe </li></ul></ul>www.ekohe.com W...
Why use Design Pattern <ul><li>For reuse </li></ul>www.ekohe.com Web Development & Graphic Design China Ruby on Rails Deve...
Why use Design Pattern <ul><li>For communication </li></ul>www.ekohe.com Web Development & Graphic Design China Ruby on Ra...
Why use Design Pattern <ul><li>For communication </li></ul>www.ekohe.com Web Development & Graphic Design China Ruby on Ra...
Difference from java to ruby <ul><li>Classes are Objects </li></ul><ul><li>Messages, not function call </li></ul><ul><li>D...
Singleton Pattern <ul><li>ensures a class has only one instance, and provides a global point of access to it </li></ul>www...
Singleton Pattern www.ekohe.com Web Development & Graphic Design China Ruby on Rails Development - Rails Consulting - Rail...
Singleton Pattern  -- java <ul><li>Eager loading </li></ul><ul><li>Lazy loading </li></ul>www.ekohe.com Web Development & ...
Singleton Pattern  -- ruby <ul><li>Ruby built-in singleton </li></ul>www.ekohe.com Web Development & Graphic Design China ...
www.ekohe.com Web Development & Graphic Design China Ruby on Rails Development - Rails Consulting - Rails Services - Merb ...
<ul><li>Built-in (Singleton) </li></ul>www.ekohe.com Web Development & Graphic Design China Ruby on Rails Development - Ra...
Observer Pattern <ul><li>defines a one-to-many dependency between objects so that when one object changes state, all of it...
Observer Pattern www.ekohe.com Web Development & Graphic Design China Ruby on Rails Development - Rails Consulting - Rails...
Observer Pattern  -- java www.ekohe.com Web Development & Graphic Design China Ruby on Rails Development - Rails Consultin...
Observer Pattern  -- java www.ekohe.com Web Development & Graphic Design China Ruby on Rails Development - Rails Consultin...
Observer Pattern  -- java <ul><li>Java built-in observer </li></ul>www.ekohe.com Web Development & Graphic Design China Ru...
Observer Pattern  -- ruby <ul><li>Ruby built-in observer </li></ul>www.ekohe.com Web Development & Graphic Design China Ru...
www.ekohe.com Web Development & Graphic Design China Ruby on Rails Development - Rails Consulting - Rails Services - Merb ...
<ul><li>Built-in (Singleton,  Observer ) </li></ul><ul><li>Mixin </li></ul>www.ekohe.com Web Development & Graphic Design ...
Iterator Pattern <ul><li>provides a way to access the elements of an aggregate object sequentially without exposing its un...
Iterator Pattern www.ekohe.com Web Development & Graphic Design China Ruby on Rails Development - Rails Consulting - Rails...
Iterator Pattern -- java www.ekohe.com Web Development & Graphic Design China Ruby on Rails Development - Rails Consulting...
Iterator Pattern -- java www.ekohe.com Web Development & Graphic Design China Ruby on Rails Development - Rails Consulting...
Iterator Pattern --  ruby <ul><li>Internal Iterator  .each </li></ul>www.ekohe.com Web Development & Graphic Design China ...
<ul><li>Built-in (Singleton, Observer,  Iterator ) </li></ul><ul><li>Mixin </li></ul>www.ekohe.com Web Development & Graph...
<ul><li>returns an instance of one of several possible classes, depending on the data provided to it.  </li></ul>www.ekohe...
www.ekohe.com Web Development & Graphic Design China Ruby on Rails Development - Rails Consulting - Rails Services - Merb ...
www.ekohe.com Web Development & Graphic Design China Ruby on Rails Development - Rails Consulting - Rails Services - Merb ...
www.ekohe.com Web Development & Graphic Design China Ruby on Rails Development - Rails Consulting - Rails Services - Merb ...
<ul><li>Classes are Objects </li></ul>www.ekohe.com Web Development & Graphic Design China Ruby on Rails Development - Rai...
<ul><li>Built-in (Singleton, Observer, Iterator)‏ </li></ul><ul><li>Mixin </li></ul><ul><li>Classes are Objects </li></ul>...
<ul><li>encapsulates a request as an object, thereby letting you parameterize clients with different requests, queue or lo...
www.ekohe.com Web Development & Graphic Design China Ruby on Rails Development - Rails Consulting - Rails Services - Merb ...
www.ekohe.com Web Development & Graphic Design China Ruby on Rails Development - Rails Consulting - Rails Services - Merb ...
<ul><li>Proc </li></ul>www.ekohe.com Web Development & Graphic Design China Ruby on Rails Development - Rails Consulting -...
<ul><li>Built-in (Singleton, Observer, Iterator)‏ </li></ul><ul><li>Mixin </li></ul><ul><li>Classes are Objects </li></ul>...
Make use of ruby advantage www.ekohe.com Web Development & Graphic Design China Ruby on Rails Development - Rails Consulti...
Principle <ul><li>DRY – Don't Repeat Yourself </li></ul><ul><li>Convention Over Configuration </li></ul>www.ekohe.com Web ...
Resources <ul><li>Design Pattern –  Elements of Reusable Object-Oriented Software </li></ul><ul><ul><li>Erich Gamma, Richa...
Q&A happy to discuss and fix my mistakes www.ekohe.com Web Development & Graphic Design China Ruby on Rails Development - ...
Upcoming SlideShare
Loading in...5
×

Design Pattern From Java To Ruby

3,806

Published on

published by Richard of Ekohe

Published in: Technology

Transcript of "Design Pattern From Java To Ruby"

  1. 1. Design Pattern -- from Java to Ruby <ul><ul><li>Richard </li></ul></ul><ul><ul><li>E kohe </li></ul></ul>www.ekohe.com Web Development & Graphic Design China Ruby on Rails Development - Rails Consulting - Rails Services - Merb - Offshore Web Development
  2. 2. Why use Design Pattern <ul><li>For reuse </li></ul>www.ekohe.com Web Development & Graphic Design China Ruby on Rails Development - Rails Consulting - Rails Services - Merb - Offshore Web Development
  3. 3. Why use Design Pattern <ul><li>For communication </li></ul>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. 4. Why use Design Pattern <ul><li>For communication </li></ul>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. 5. Difference from java to ruby <ul><li>Classes are Objects </li></ul><ul><li>Messages, not function call </li></ul><ul><li>Duck Typing </li></ul><ul><li>Mixin </li></ul>www.ekohe.com Web Development & Graphic Design China Ruby on Rails Development - Rails Consulting - Rails Services - Merb - Offshore Web Development
  6. 6. Singleton Pattern <ul><li>ensures a class has only one instance, and provides a global point of access to it </li></ul>www.ekohe.com Web Development & Graphic Design China Ruby on Rails Development - Rails Consulting - Rails Services - Merb - Offshore Web Development
  7. 7. 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
  8. 8. Singleton Pattern -- java <ul><li>Eager loading </li></ul><ul><li>Lazy loading </li></ul>www.ekohe.com Web Development & Graphic Design China Ruby on Rails Development - Rails Consulting - Rails Services - Merb - Offshore Web Development
  9. 9. Singleton Pattern -- ruby <ul><li>Ruby built-in singleton </li></ul>www.ekohe.com Web Development & Graphic Design China Ruby on Rails Development - Rails Consulting - Rails Services - Merb - Offshore Web Development
  10. 10. www.ekohe.com Web Development & Graphic Design China Ruby on Rails Development - Rails Consulting - Rails Services - Merb - Offshore Web Development
  11. 11. <ul><li>Built-in (Singleton) </li></ul>www.ekohe.com Web Development & Graphic Design China Ruby on Rails Development - Rails Consulting - Rails Services - Merb - Offshore Web Development Ruby for Design Pattern
  12. 12. Observer Pattern <ul><li>defines a one-to-many dependency between objects so that when one object changes state, all of its dependents are notified and updated automatically </li></ul>www.ekohe.com Web Development & Graphic Design China Ruby on Rails Development - Rails Consulting - Rails Services - Merb - Offshore Web Development
  13. 13. 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
  14. 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. 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. 16. Observer Pattern -- java <ul><li>Java built-in observer </li></ul>www.ekohe.com Web Development & Graphic Design China Ruby on Rails Development - Rails Consulting - Rails Services - Merb - Offshore Web Development
  17. 17. Observer Pattern -- ruby <ul><li>Ruby built-in observer </li></ul>www.ekohe.com Web Development & Graphic Design China Ruby on Rails Development - Rails Consulting - Rails Services - Merb - Offshore Web Development
  18. 18. www.ekohe.com Web Development & Graphic Design China Ruby on Rails Development - Rails Consulting - Rails Services - Merb - Offshore Web Development
  19. 19. <ul><li>Built-in (Singleton, Observer ) </li></ul><ul><li>Mixin </li></ul>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. 20. Iterator Pattern <ul><li>provides a way to access the elements of an aggregate object sequentially without exposing its underlying representation </li></ul>www.ekohe.com Web Development & Graphic Design China Ruby on Rails Development - Rails Consulting - Rails Services - Merb - Offshore Web Development
  21. 21. 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
  22. 22. Iterator Pattern -- java www.ekohe.com Web Development & Graphic Design China Ruby on Rails Development - Rails Consulting - Merb - Offshore Web Development <ul><li>External Iterator </li></ul>
  23. 23. Iterator Pattern -- java www.ekohe.com Web Development & Graphic Design China Ruby on Rails Development - Rails Consulting - Merb - Offshore Web Development <ul><li>Internal Iterator </li></ul>
  24. 24. Iterator Pattern -- ruby <ul><li>Internal Iterator .each </li></ul>www.ekohe.com Web Development & Graphic Design China Ruby on Rails Development - Rails Consulting - Rails Services - Merb - Offshore Web Development
  25. 25. <ul><li>Built-in (Singleton, Observer, Iterator ) </li></ul><ul><li>Mixin </li></ul>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. 26. <ul><li>returns an instance of one of several possible classes, depending on the data provided to it. </li></ul>www.ekohe.com Web Development & Graphic Design China Ruby on Rails Development - Rails Consulting - Rails Services - Merb - Offshore Web Development Simple Factory Pattern
  27. 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. 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. 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. 30. <ul><li>Classes are Objects </li></ul>www.ekohe.com Web Development & Graphic Design China Ruby on Rails Development - Rails Consulting - Rails Services - Merb - Offshore Web Development Simple Factory Pattern -- ruby
  31. 31. <ul><li>Built-in (Singleton, Observer, Iterator)‏ </li></ul><ul><li>Mixin </li></ul><ul><li>Classes are Objects </li></ul>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. 32. <ul><li>encapsulates a request as an object, thereby letting you parameterize clients with different requests, queue or log requests, and support undoable operations. </li></ul>www.ekohe.com Web Development & Graphic Design China Ruby on Rails Development - Rails Consulting - Rails Services - Merb - Offshore Web Development Command Pattern
  33. 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. 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. 35. <ul><li>Proc </li></ul>www.ekohe.com Web Development & Graphic Design China Ruby on Rails Development - Rails Consulting - Rails Services - Merb - Offshore Web Development Command Pattern -- ruby
  36. 36. <ul><li>Built-in (Singleton, Observer, Iterator)‏ </li></ul><ul><li>Mixin </li></ul><ul><li>Classes are Objects </li></ul><ul><li>Proc </li></ul>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. 37. 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
  38. 38. Principle <ul><li>DRY – Don't Repeat Yourself </li></ul><ul><li>Convention Over Configuration </li></ul>www.ekohe.com Web Development & Graphic Design China Ruby on Rails Development - Rails Consulting - Rails Services - Merb - Offshore Web Development
  39. 39. Resources <ul><li>Design Pattern – Elements of Reusable Object-Oriented Software </li></ul><ul><ul><li>Erich Gamma, Richard Helm, Ralph Johnson, John Vlissides </li></ul></ul><ul><li>Head First Design Pattern </li></ul><ul><ul><ul><li>Kathy Sierra, Bert Bates </li></ul></ul></ul><ul><li>Design Pattern in Ruby </li></ul><ul><ul><ul><li>Russ Olsen </li></ul></ul></ul>www.ekohe.com Web Development & Graphic Design China Ruby on Rails Development - Rails Consulting - Rails Services - Merb - Offshore Web Development
  40. 40. 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
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×