Your SlideShare is downloading. ×
Marat Kamenschykov. GoF Patterns + Rails =?
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×

Introducing the official SlideShare app

Stunning, full-screen experience for iPhone and Android

Text the download link to your phone

Standard text messaging rates apply

Marat Kamenschykov. GoF Patterns + Rails =?

2,088
views

Published on

Published in: Technology

0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
2,088
On Slideshare
0
From Embeds
0
Number of Embeds
4
Actions
Shares
0
Downloads
13
Comments
0
Likes
0
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. Rails + GoF Patterns = ? Marat Kamenschikov Svitla Systems Inc.
  • 2. GoF = Gang of Four : Erich Gamma Richard Helm Ralph Johnson John Vlissides
  • 3.  
  • 4.  
  • 5. Design Patterns: Elements of Reusable Object-Oriented Software With foreword of Grady Booch Printed on October 21, 1994 as of July 2010, the book was in its 38th printing 500,000 copies have been sold in English and in 13 other languages.
  • 6. 23 reusable design patterns
    • 3 parts:
    • Structural patterns
    • Creational patterns
    • Behavioral patterns
  • 7. Creational patterns
    • C reate objects for you, rather than having you instantiate objects directly
    • 5 patterns:
      • Abstract Factory
      • Builder ( Строитель )
      • Factory Method
      • Prototype
      • Singleton ( Одиночка )
  • 8. Structural patterns
    • C lass and object composition
    • 7 patterns:
      • Adapter ( Адаптер )
      • Bridge
      • Composite
      • Decorator
      • Façade ( Фасад )
      • Flyweight ( Приспособленец )
      • Proxy ( Заместитель )
  • 9. Behavioral patterns
    • C ommunication between objects
    • 11 patterns:
      • Chain of responsibility
      • Command
      • Interpreter
      • Iterator
      • Mediator
      • Memento
      • Observer
      • State
      • Strategy
      • Template method
      • Visitor
  • 10. Project overview
    • Web-interface for IP-telephony service subscribers
    • 3 WSDL services
    • 3+ XML services
    • 5 foreign MySQL DBs
    • Local MySQL DB for structuring the incoming info
  • 11. DB XML WSDL WSDL WSDL XML XML DB DB DB DB Web-app with DB
  • 12. Purpose of my talk:
    • Which GoF patterns we were able to use?
    • How did they couple with Rails?
    • Results: what is good and what is bad
  • 13.  
  • 14. Project challenges
    • Not GUI-oriented Servers Object structure
    • Requirement to store settings in local DB on login to support several parallel sessions
    • Rails
  • 15. Not GUI-oriented Servers Object structure
    • Web-app: single system with a straight structure – 1 root object and others are associated
    • Services and remote DBs: distributed system with various authenticating procedures and ways to retrieve data
  • 16. Ideal data structure (initial web-app design)
  • 17. Services structure
  • 18. It’s almost completely different!!!
  • 19. And not only in data structure!!!
  • 20.  
  • 21.  
  • 22.  
  • 23.  
  • 24.  
  • 25.  
  • 26.  
  • 27.  
  • 28. Façade Façade
  • 29. Façade
  • 30. Singleton
  • 31. Builder
  • 32. Flyweight
  • 33. Flyweight
  • 34. Proxy
  • 35. Façade
    • class ConnectionAdapter
    • end
  • 36. Singleton
  • 37.  
  • 38.
    • @@
  • 39.  
  • 40. Flyweight Id | name 1 | Nick User < AR id: 1 name: Nick User.find(1) User.find_by_id(1) User.find_by_name(‘Nick’)
  • 41.
    • Identity map:
    • https://github.com/pjdavis/identity-map
  • 42. Builder
    • Tried to build ideal structure of what we had: FAIL!
  • 43. Finally
  • 44. Proxy
  • 45. UserSession < AR::Base
  • 46.  
  • 47.  
  • 48.  
  • 49. Results
    • UserSession is the only singleton and eventually Façade in Rails
    • Don’t build ideal data model, build what is needed
    • Identity Map requires different approach to associations but still awesome
    • Lazy loading is cool!
  • 50. Thank you!