Your SlideShare is downloading. ×

Design Pattern From Java To Ruby

3,774

Published on

published by Richard of Ekohe

published by Richard of Ekohe

Published in: Technology
0 Comments
8 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
3,774
On Slideshare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
97
Comments
0
Likes
8
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide
  • Transcript

    • 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 Design Pattern
      • 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 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?
    • 4. 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?
    • 5. 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
    • 6. 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
    • 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. 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.com Web Development & Graphic Design China Ruby on Rails Development - Rails Consulting - Rails Services - Merb - Offshore Web Development Ruby for Design Pattern
    • 12. 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
    • 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. 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
      • 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
    • 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. 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 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
    • 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 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
    • 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 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
    • 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 Web Development & 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 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. 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 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

    ×