Save 37% off PRO during our Black Friday Sale! »

Advanced design patterns

Advanced design patterns

A tour of advanced design patterns in Python, including MVC, KVO and ORM.

4885da39b4bc6628c5599eb9253dcf32?s=128

Marek Stępniowski

January 09, 2012
Tweet

Transcript

  1. Złożone wzorce projektowe MVC, KVO, ORM. Z czym to się

    je?
  2. Marek Stępniowski http://stepniowski.com @mstepniowski

  3. Gamma, et al. Design Patterns Time Hunt, Thomas The Pragmatic

    Programmer Martin Fowler Patterns of Enterprise Application Architecture Cormen, et al. Introduction to Algorithms Kent Beck Test-Driven Development Python Abelson, Sussman Structure and Interpretation of Computer Programs Chris Okasaki Purely Functional Data Structures My first language Stages of a programmer Level 9000 0
  4. Gamma, et al. Design Patterns Hunt, Thomas The Pragmatic Programmer

    Cormen, et al. Introduction to Algorithms thon
  5. t al. erns as atic er Martin Fowler Patterns of

    Enterprise Application Architecture Test-Driven Development Abelson, Sussman Structure and Interpretation of Computer Programs
  6. Wzorce projektowe Architektura dużych aplikacji w Pythonie last year

  7. Design pattern def. General reusable solution to a commonly occurring

    problem within a given context in software design. A design pattern is a description or template for how to solve a problem that can be used in many different situations. last year
  8. Alan Shallowey James R. Trott last year

  9. Abstract Factory Factory Method Builder Prototype Singleton Adapter Bridge Composite

    Decorator Facade Flyweight Proxy Chain of Reponsibility Command Interpreter Iterator Mediator Memento Observer State Strategy Template Method Visitor DP last year
  10. Adapter Bridge Composite Decorator Facade Flyweight Proxy Memento Observer State

    Strategy Template Method Visitor Multiton Object Pool RAII Front Controller Null Object Publish/Subscribe Blackboard Servant Specification CC last year
  11. Foreign Key Mapping Association Table Mapping Dependent Mapping Embedded Value

    Serialized LOB Single Table Inheritance Class Table Inheritance Concrete Table Inheritance Inheritance Mappers Metadata Mapping Database Session State Gateway Mapper Layer Subtype Separated Interface Registry Value Object Money Special Case Plugin Service Stub Record Set PoEAA last year
  12. Embedded Value Serialized LOB Single Table Inheritance Class Table Inheritance

    Concrete Table Inheritance Inheritance Mappers Metadata Mapping Separated Interface Registry Value Object Money Special Case Plugin Service Stub Record Set Model Template View Model View Presenter Model View ViewModel Layers KVO KVC inne last year
  13. hipotetyczna firma last year

  14. Adapter Abstract Factory Method Factory Template Method Null Object Plugin

    Strategy Observer State 9 last year 9/86
  15. My God! It’s full of patterns! last year

  16. A B last year

  17. A B last year

  18. A B C last year

  19. A B C last year

  20. A B C last year

  21. Patternitis last year

  22. No silver bullet! last year

  23. MVC ORM bindings KVO KVC delegate responder chain run loop

    observer unit of work data mapper identity map active record
  24. None
  25. MVC Model View Controller

  26. Controller Model View MVC

  27. Controller Model View MVC

  28. Controller Model View MVC

  29. +notify(*) Observer +notify(*) ObserverA +notify(*) ObserverB notifyObservers(*) for observer in

    observerCollection: observer.notify(*) +registerObserver(1) +unregisterObserver(1) +notifyObservers(*) observerCollection Observable Observer
  30. View Model Model 1

  31. Front Controller View Model Model 1

  32. Front Controller View Model Model 2 Template

  33. None
  34. None
  35. MVC Controller View Model

  36. MVC Controller View Model Subview1 Subview2

  37. MVC Controller View Model Subview1 Subview2 Subcont1 Subcont2

  38. MVC Controller View Model Subview1 Subview2 Subcont1 Subcont2

  39. None
  40. MVC Controller View Model Subview1 Subview2 Subcont1 Subcont2

  41. MVC Controller View Model Subview1 Subview2 Subcont1 Subcont2 responder chain

  42. MVC Controller View Model Subview1 Subview2 Subcont1 Subcont2 first responder

  43. MVP Controller View Model Subview1 Subview2

  44. MVP Controller View Model Subview1 Subview2

  45. MVP Controller View Model Widget1 Widget2 View Widget Presenter

  46. KVC Key-Value Coding

  47. KVC Model Widget1 Widget2 View Presenter Widget widget

  48. KVC Model Widget1 Widget2 View Presenter Widget widget.widget2

  49. KVC Model Widget1 Widget2 View Presenter Widget widget.widget2.attr attr @avg

    @count @min @sum @distinctUnionOfSets
  50. KVO Key-Value Observing

  51. setName @property changed:name

  52. bindings

  53. run loop

  54. ember • MVC • Templates • KVC/KVO • MVP •

    Templates • KVC/KVO • bindings • run loop
  55. Person = Ember.Object.extend({ firstName: null, lastName: null, fullName: Ember.computed(function(key, value)

    { // getter if (arguments.length === 1) { var firstName = this.get('firstName'); var lastName = this.get('lastName'); return firstName + ' ' + lastName; // setter } else { var name = value.split(" "); this.set('firstName', name[0]); this.set('lastName', name[1]); return value; } }).property('firstName', 'lastName') }); var person = Person.create(); person.set('fullName', "Peter Wagenet"); person.get('firstName') // Peter person.get('lastName') // Wagenet
  56. ORM Object-relational mapping

  57. ORM Active Record Data Mapper Unit of Work

  58. Active Record

  59. class Person(Entity): name = Field(String(128)) addresses = OneToMany('Address') class Address(Entity):

    email = Field(Unicode(128)) owner = ManyToOne('Person')
  60. Data Mapper

  61. Unit of Work

  62. Identity Map

  63. Lazy Load

  64. ORM Active Record Data Mapper Unit of Work

  65. ORM Active Record Data Mapper Unit of Work

  66. Marek Stępniowski http://stepniowski.com @mstepniowski

  67. http://stepniowski.com/p/patterns