Your SlideShare is downloading. ×
0
Advanced OO Patterns         ConFoo 2011Tobias Schlitt <toby@qafoo.com>        March 9, 2011
Advanced OO Patterns       2 / 44    Outline    Introduction    Lazy Initialization    Dependency Injection    Service Loc...
Advanced OO Patterns                   3 / 44    About me        Degree in computer sience        More than 10 years of   ...
Advanced OO Patterns                   3 / 44    About me        Degree in computer sience        More than 10 years of   ...
Advanced OO Patterns                   3 / 44    About me        Degree in computer sience        More than 10 years of   ...
Advanced OO Patterns                                                    3 / 44    About me        Degree in computer sienc...
Advanced OO Patterns                                                        3 / 44    About me        Degree in computer s...
Advanced OO Patterns                                        4 / 44    Disclaimer         This talk cannot be in depth     ...
Advanced OO Patterns                                        4 / 44    Disclaimer         This talk cannot be in depth     ...
Advanced OO Patterns                                        4 / 44    Disclaimer         This talk cannot be in depth     ...
Advanced OO Patterns                                        4 / 44    Disclaimer         This talk cannot be in depth     ...
Advanced OO Patterns                                        4 / 44    Disclaimer         This talk cannot be in depth     ...
Advanced OO Patterns                  5 / 44    Patterns are . . .         . . . universal solutions.         . . . good h...
Advanced OO Patterns                  5 / 44    Patterns are . . .         . . . universal solutions.         . . . good h...
Advanced OO Patterns                  5 / 44    Patterns are . . .         . . . universal solutions.         . . . good h...
Advanced OO Patterns                  5 / 44    Patterns are . . .         . . . universal solutions.         . . . good h...
Advanced OO Patterns                  5 / 44    Patterns are . . .         . . . universal solutions.         . . . good h...
Advanced OO Patterns                  5 / 44    Patterns are . . .         . . . universal solutions.         . . . good h...
Advanced OO Patterns                                                 5 / 44    Patterns are . . .         . . . universal ...
Advanced OO Patterns                            6 / 44    Patterns are not . . .         . . . appliable to every problem....
Advanced OO Patterns        7 / 44    Pattern classification         Creational         Structural         Behavioural     ...
Advanced OO Patterns                                                  8 / 44    Well known patterns                       ...
Advanced OO Patterns                                                  8 / 44    Well known patterns                       ...
Advanced OO Patterns       9 / 44    Outline    Introduction    Lazy Initialization    Dependency Injection    Service Loc...
Advanced OO Patterns                                             10 / 44    Motivation         Building a full object grap...
Advanced OO Patterns                                             10 / 44    Motivation         Building a full object grap...
Advanced OO Patterns                                             10 / 44    Motivation         Building a full object grap...
Advanced OO Patterns                                                                11 / 44     Simple lazy initialization...
Advanced OO Patterns                                                                11 / 44     Simple lazy initialization...
Advanced OO Patterns                                                                11 / 44     Simple lazy initialization...
Advanced OO Patterns       12 / 44    Outline    Introduction    Lazy Initialization    Dependency Injection    Service Lo...
Advanced OO Patterns                                                  13 / 44    Goals of good OO design         Modular  ...
Advanced OO Patterns                                                  13 / 44    Goals of good OO design         Modular  ...
Advanced OO Patterns                                                  13 / 44    Goals of good OO design         Modular  ...
Advanced OO Patterns                                                  13 / 44    Goals of good OO design         Modular  ...
Advanced OO Patterns                                                  13 / 44    Goals of good OO design         Modular  ...
Advanced OO Patterns                                                                            14 / 44     What’s the pro...
Advanced OO Patterns                                                                            14 / 44     What’s the pro...
Advanced OO Patterns                                                                            14 / 44     What’s the pro...
Advanced OO Patterns                                                                            14 / 44     What’s the pro...
Advanced OO Patterns                                                                                                      ...
Advanced OO Patterns                                                                                                      ...
Advanced OO Patterns                                                                                                      ...
Advanced OO Patterns                                                                                                      ...
Advanced OO Patterns                                                                                                      ...
Advanced OO Patterns                                                                                                      ...
Advanced OO Patterns                           16 / 44    What is desired?         Don’t have ctors all over the place    ...
Advanced OO Patterns                               17 / 44    The Arbit DIC         Exemplary for a high-end DIC          ...
Advanced OO Patterns                               17 / 44    The Arbit DIC         Exemplary for a high-end DIC          ...
Advanced OO Patterns                               17 / 44    The Arbit DIC         Exemplary for a high-end DIC          ...
Advanced OO Patterns                               17 / 44    The Arbit DIC         Exemplary for a high-end DIC          ...
Advanced OO Patterns                                                           18 / 44     Managing dependencies 3   c l a...
Advanced OO Patterns                                                           18 / 44     Managing dependencies 3   c l a...
Advanced OO Patterns                                                                                                      ...
Advanced OO Patterns                                                             20 / 44     Managing dependencies 3   c l...
Advanced OO Patterns                                                                                                     2...
Advanced OO Patterns                        22 / 44    Dependency Injection Approaches         Constructor injection      ...
Advanced OO Patterns                        22 / 44    Dependency Injection Approaches         Constructor injection      ...
Advanced OO Patterns                        22 / 44    Dependency Injection Approaches         Constructor injection      ...
Advanced OO Patterns                                               23 / 44    More about DIC         Phemto - A dependency...
Advanced OO Patterns                                               23 / 44    More about DIC         Phemto - A dependency...
Advanced OO Patterns       24 / 44    Outline    Introduction    Lazy Initialization    Dependency Injection    Service Lo...
Advanced OO Patterns                                   25 / 44    Service Locator         Object to retrieve a Service fro...
Advanced OO Patterns                                   25 / 44    Service Locator         Object to retrieve a Service fro...
Advanced OO Patterns                                                                            26 / 44     Service Locato...
Advanced OO Patterns                                                                            26 / 44     Service Locato...
Advanced OO Patterns                                                                            26 / 44     Service Locato...
Advanced OO Patterns                                                                            26 / 44     Service Locato...
Advanced OO Patterns                             27 / 44    Pattern purism                       DIC vs. Service Locator
Advanced OO Patterns       28 / 44    Outline    Introduction    Lazy Initialization    Dependency Injection    Service Lo...
Advanced OO Patterns                         29 / 44    The situation             Model (application)   Storage
Advanced OO Patterns                                   29 / 44    The situation             Model (application)           ...
Advanced OO Patterns                                  30 / 44    Challenges         Model and storage structure differ     ...
Advanced OO Patterns                                  30 / 44    Challenges         Model and storage structure differ     ...
Advanced OO Patterns                                  30 / 44    Challenges         Model and storage structure differ     ...
Advanced OO Patterns                                  30 / 44    Challenges         Model and storage structure differ     ...
Advanced OO Patterns                                  30 / 44    Challenges         Model and storage structure differ     ...
Advanced OO Patterns                                  30 / 44    Challenges         Model and storage structure differ     ...
Advanced OO Patterns                                  30 / 44    Challenges         Model and storage structure differ     ...
Advanced OO Patterns                                 31 / 44     Active Record 1   <?php 2 3   class Invoice          exte...
Advanced OO Patterns                                 31 / 44     Active Record 1   <?php 2 3   class Invoice          exte...
Advanced OO Patterns                                 31 / 44     Active Record 1   <?php 2 3   class Invoice          exte...
Advanced OO Patterns                                 31 / 44     Active Record 1   <?php 2 3   class Invoice          exte...
Advanced OO Patterns                                  32 / 44    Active Record         Combines storage and business logic...
Advanced OO Patterns                                     33 / 44    Evaluation               Pros                    Cons ...
Advanced OO Patterns                                     33 / 44    Evaluation               Pros                    Cons ...
Advanced OO Patterns                                     33 / 44    Evaluation               Pros                    Cons ...
Advanced OO Patterns                                     33 / 44    Evaluation               Pros                    Cons ...
Advanced OO Patterns                                     33 / 44    Evaluation               Pros                    Cons ...
Advanced OO Patterns                                     33 / 44    Evaluation               Pros                    Cons ...
Advanced OO Patterns                                     33 / 44    Evaluation               Pros                    Cons ...
Advanced OO Patterns                                     33 / 44    Evaluation               Pros                    Cons ...
Advanced OO Patterns                                   34 / 44    Lesson learned . . .               De-couple business an...
Advanced OO Patterns                                                    35 / 44     Row Data Gateway 1   <?php 2 3   class...
Advanced OO Patterns                                                    35 / 44     Row Data Gateway 1   <?php 2 3   class...
Advanced OO Patterns                                                    35 / 44     Row Data Gateway 1   <?php 2 3   class...
Advanced OO Patterns                                                    35 / 44     Row Data Gateway 1   <?php 2 3   class...
Advanced OO Patterns                                           36 / 44    Row Data Gateway         Decouples storage from ...
Advanced OO Patterns                                           36 / 44    Row Data Gateway         Decouples storage from ...
Advanced OO Patterns                                         37 / 44    Evaluation                  Pros                  ...
Advanced OO Patterns                                         37 / 44    Evaluation                  Pros                  ...
Advanced OO Patterns                                         37 / 44    Evaluation                  Pros                  ...
Advanced OO Patterns                                         37 / 44    Evaluation                  Pros                  ...
Advanced OO Patterns                                         37 / 44    Evaluation                  Pros                  ...
Advanced OO Patterns                                                                              38 / 44     Data Mapper ...
Advanced OO Patterns                                                                              38 / 44     Data Mapper ...
Advanced OO Patterns                                                                              38 / 44     Data Mapper ...
Advanced OO Patterns                                                                              38 / 44     Data Mapper ...
Advanced OO Patterns                                  39 / 44    Data Mapper         Decouple storage from model         N...
Advanced OO Patterns                                            40 / 44    Evaluation                       Pros          ...
Advanced OO Patterns                                            40 / 44    Evaluation                       Pros          ...
Advanced OO Patterns                                            40 / 44    Evaluation                       Pros          ...
Advanced OO Patterns                                            40 / 44    Evaluation                       Pros          ...
Advanced OO Patterns                                            40 / 44    Evaluation                       Pros          ...
Advanced OO Patterns                                            40 / 44    Evaluation                       Pros          ...
Advanced OO Patterns                                            40 / 44    Evaluation                       Pros          ...
Advanced OO Patterns                                            40 / 44    Evaluation                       Pros          ...
Advanced OO Patterns                                              41 / 44    Attribution                       Large parts...
Advanced OO Patterns                            42 / 44    Conclusion         Patterns are not the holy grail!         The...
Advanced OO Patterns                            42 / 44    Conclusion         Patterns are not the holy grail!         The...
Advanced OO Patterns                                   43 / 44    Q/A                       Are there any questions left?
Advanced OO Patterns                                         44 / 44    Thanks for listening                          Plea...
Advanced OO Patterns                                         44 / 44    Thanks for listening                           Ple...
Advanced OO Patterns                                         44 / 44    Thanks for listening                          Plea...
Upcoming SlideShare
Loading in...5
×

Confoo 2011 - Advanced OO Patterns

1,506

Published on

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

No Downloads
Views
Total Views
1,506
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
31
Comments
0
Likes
5
Embeds 0
No embeds

No notes for slide

Transcript of "Confoo 2011 - Advanced OO Patterns"

  1. 1. Advanced OO Patterns ConFoo 2011Tobias Schlitt <toby@qafoo.com> March 9, 2011
  2. 2. Advanced OO Patterns 2 / 44 Outline Introduction Lazy Initialization Dependency Injection Service Locator Data Storage
  3. 3. Advanced OO Patterns 3 / 44 About me Degree in computer sience More than 10 years of professional PHP Open source enthusiast Apache Zeta Components Arbit PHPUnit ...
  4. 4. Advanced OO Patterns 3 / 44 About me Degree in computer sience More than 10 years of professional PHP Open source enthusiast Apache Zeta Components Arbit PHPUnit ...
  5. 5. Advanced OO Patterns 3 / 44 About me Degree in computer sience More than 10 years of professional PHP Open source enthusiast Apache Zeta Components Arbit PHPUnit ...
  6. 6. Advanced OO Patterns 3 / 44 About me Degree in computer sience Co-Founder of More than 10 years of Qafoo GmbH professional PHP http://qafoo.com Open source enthusiast Apache Zeta Components Qafoo passion for software quality Arbit PHPUnit ...
  7. 7. Advanced OO Patterns 3 / 44 About me Degree in computer sience Co-Founder of More than 10 years of Qafoo GmbH professional PHP http://qafoo.com Open source enthusiast Apache Zeta Components Qafoo passion for software quality Arbit We help people to produce PHPUnit ... high quality PHP code.
  8. 8. Advanced OO Patterns 4 / 44 Disclaimer This talk cannot be in depth This talk shall inspire you This talk will not show UML diagrams This talk will show you quite some code This talk can seriously harm your coding habbits
  9. 9. Advanced OO Patterns 4 / 44 Disclaimer This talk cannot be in depth This talk shall inspire you This talk will not show UML diagrams This talk will show you quite some code This talk can seriously harm your coding habbits
  10. 10. Advanced OO Patterns 4 / 44 Disclaimer This talk cannot be in depth This talk shall inspire you This talk will not show UML diagrams This talk will show you quite some code This talk can seriously harm your coding habbits
  11. 11. Advanced OO Patterns 4 / 44 Disclaimer This talk cannot be in depth This talk shall inspire you This talk will not show UML diagrams This talk will show you quite some code This talk can seriously harm your coding habbits
  12. 12. Advanced OO Patterns 4 / 44 Disclaimer This talk cannot be in depth This talk shall inspire you This talk will not show UML diagrams This talk will show you quite some code This talk can seriously harm your coding habbits
  13. 13. Advanced OO Patterns 5 / 44 Patterns are . . . . . . universal solutions. . . . good habbits. . . . coding templates.
  14. 14. Advanced OO Patterns 5 / 44 Patterns are . . . . . . universal solutions. . . . good habbits. . . . coding templates.
  15. 15. Advanced OO Patterns 5 / 44 Patterns are . . . . . . universal solutions. . . . good habbits. . . . coding templates.
  16. 16. Advanced OO Patterns 5 / 44 Patterns are . . . . . . universal solutions. . . . good habbits. . . . coding templates.
  17. 17. Advanced OO Patterns 5 / 44 Patterns are . . . . . . universal solutions. . . . good habbits. . . . coding templates.
  18. 18. Advanced OO Patterns 5 / 44 Patterns are . . . . . . universal solutions. . . . good habbits. . . . coding templates.
  19. 19. Advanced OO Patterns 5 / 44 Patterns are . . . . . . universal solutions. . . . good habbits. . . . coding templates. . . . names for proven ideas how a certain class of problems can be solved.
  20. 20. Advanced OO Patterns 6 / 44 Patterns are not . . . . . . appliable to every problem. . . . directly transferable to code. . . . always the best solution.
  21. 21. Advanced OO Patterns 7 / 44 Pattern classification Creational Structural Behavioural Architectural
  22. 22. Advanced OO Patterns 8 / 44 Well known patterns Signal / Observer Iterator Visitor Adapter Singleton Factory
  23. 23. Advanced OO Patterns 8 / 44 Well known patterns Signal / Observer Iterator Visitor Adapter Singleton Factory
  24. 24. Advanced OO Patterns 9 / 44 Outline Introduction Lazy Initialization Dependency Injection Service Locator Data Storage
  25. 25. Advanced OO Patterns 10 / 44 Motivation Building a full object graph is Complex Time consuming Memory consuming Do you use all objects in every request? Idea: Initialize object when needed for the first time
  26. 26. Advanced OO Patterns 10 / 44 Motivation Building a full object graph is Complex Time consuming Memory consuming Do you use all objects in every request? Idea: Initialize object when needed for the first time
  27. 27. Advanced OO Patterns 10 / 44 Motivation Building a full object graph is Complex Time consuming Memory consuming Do you use all objects in every request? Idea: Initialize object when needed for the first time
  28. 28. Advanced OO Patterns 11 / 44 Simple lazy initialization 1 <?php 2 3 class DatabaseInitializer 4 { 5 p r o t e c t e d $dsn ; 6 7 p r o t e c t e d $db ; 8 9 public function c o n s t r u c t ( $dsn )10 {11 $ t h i s − sn = $dsn ; >d12 }1314 p u b l i c f u n c t i o n getDatabase ()15 {16 i f ( $this− >db === n u l l )17 {18 $this− >db = new D a t a b a s e ( $ t h i s − s n ) ; >d19 }20 return $this− >db ;21 }22 }
  29. 29. Advanced OO Patterns 11 / 44 Simple lazy initialization 1 <?php 2 3 class DatabaseInitializer 4 { 5 p r o t e c t e d $dsn ; 6 7 p r o t e c t e d $db ; 8 9 public function c o n s t r u c t ( $dsn )10 {11 $ t h i s − sn = $dsn ; >d12 }1314 p u b l i c f u n c t i o n getDatabase ()15 {16 i f ( $this− >db === n u l l )17 {18 $this− >db = new D a t a b a s e ( $ t h i s − s n ) ; >d19 }20 return $this− >db ;21 }22 }
  30. 30. Advanced OO Patterns 11 / 44 Simple lazy initialization 1 <?php 2 3 class DatabaseInitializer 4 { 5 p r o t e c t e d $dsn ; 6 7 p r o t e c t e d $db ; 8 9 public function c o n s t r u c t ( $dsn )10 {11 $ t h i s − sn = $dsn ; >d12 }1314 p u b l i c f u n c t i o n getDatabase ()15 {16 i f ( $this− >db === n u l l )17 {18 $this− >db = new D a t a b a s e ( $ t h i s − s n ) ; >d19 }20 return $this− >db ;21 }22 }
  31. 31. Advanced OO Patterns 12 / 44 Outline Introduction Lazy Initialization Dependency Injection Service Locator Data Storage
  32. 32. Advanced OO Patterns 13 / 44 Goals of good OO design Modular Flexible Reusable Testable S.O.L.I.D. (http://butunclebob.com/ArticleS.UncleBob.PrinciplesOfOod)
  33. 33. Advanced OO Patterns 13 / 44 Goals of good OO design Modular Flexible Reusable Testable S.O.L.I.D. (http://butunclebob.com/ArticleS.UncleBob.PrinciplesOfOod)
  34. 34. Advanced OO Patterns 13 / 44 Goals of good OO design Modular Flexible Reusable Testable S.O.L.I.D. (http://butunclebob.com/ArticleS.UncleBob.PrinciplesOfOod)
  35. 35. Advanced OO Patterns 13 / 44 Goals of good OO design Modular Flexible Reusable Testable S.O.L.I.D. (http://butunclebob.com/ArticleS.UncleBob.PrinciplesOfOod)
  36. 36. Advanced OO Patterns 13 / 44 Goals of good OO design Modular Flexible Reusable Testable S.O.L.I.D. (http://butunclebob.com/ArticleS.UncleBob.PrinciplesOfOod)
  37. 37. Advanced OO Patterns 14 / 44 What’s the problem here? 1 <?php 2 3 c l a s s MessageDispatcher 4 { Inflexible 5 public function construct () 6 7 { $this−>m e s s e n g e r s [ ] = new Not reusable JabberMessenger () ; 8 $this−>m e s s e n g e r s [ ] = new Hardly testable MailMessenger () ; 9 }10 }1112 c l a s s MailMessenger implements Messenger13 {14 p u b l i c f u n c t i o n sendMessage ( $ t e x t )15 {16 myLogger : : g e t I n s t a n c e ( )− o g ( $ t e x t >l );17 $ t h i s − e n d M a i l ( /∗ . . . ∗/ ) ; >s18 }19 }
  38. 38. Advanced OO Patterns 14 / 44 What’s the problem here? 1 <?php 2 3 c l a s s MessageDispatcher 4 { Inflexible 5 public function construct () 6 7 { $this−>m e s s e n g e r s [ ] = new Not reusable JabberMessenger () ; 8 $this−>m e s s e n g e r s [ ] = new Hardly testable MailMessenger () ; 9 }10 }1112 c l a s s MailMessenger implements Messenger13 {14 p u b l i c f u n c t i o n sendMessage ( $ t e x t )15 {16 myLogger : : g e t I n s t a n c e ( )− o g ( $ t e x t >l );17 $ t h i s − e n d M a i l ( /∗ . . . ∗/ ) ; >s18 }19 }
  39. 39. Advanced OO Patterns 14 / 44 What’s the problem here? 1 <?php 2 3 c l a s s MessageDispatcher 4 { Inflexible 5 public function construct () 6 7 { $this−>m e s s e n g e r s [ ] = new Not reusable JabberMessenger () ; 8 $this−>m e s s e n g e r s [ ] = new Hardly testable MailMessenger () ; 9 }10 }1112 c l a s s MailMessenger implements Messenger13 {14 p u b l i c f u n c t i o n sendMessage ( $ t e x t )15 {16 myLogger : : g e t I n s t a n c e ( )− o g ( $ t e x t >l );17 $ t h i s − e n d M a i l ( /∗ . . . ∗/ ) ; >s18 }19 }
  40. 40. Advanced OO Patterns 14 / 44 What’s the problem here? 1 <?php 2 3 c l a s s MessageDispatcher 4 { Inflexible 5 public function construct () 6 7 { $this−>m e s s e n g e r s [ ] = new Not reusable JabberMessenger () ; 8 $this−>m e s s e n g e r s [ ] = new Hardly testable MailMessenger () ; 9 }10 }1112 c l a s s MailMessenger implements Messenger13 {14 p u b l i c f u n c t i o n sendMessage ( $ t e x t )15 {16 myLogger : : g e t I n s t a n c e ( )− o g ( $ t e x t >l );17 $ t h i s − e n d M a i l ( /∗ . . . ∗/ ) ; >s18 }19 }
  41. 41. Advanced OO Patterns 15 / 44 Injecting dependencies 1 <?php 2 3 $ m e s s e n g e r = new M e s s a g e D i s p a t c h e r ( 4 array ( 5 new J a b b e r M e s s e n g e r ( ’ j a b b e r . e x a m p l e . o r g ’ , ’ u s e r ’ , ’ p a s s ’ ) , 6 new M a i l M e s s e n g e r ( 7 new M a i l S m t p T r a n s p o r t ( ’ m a i l . e x a m p l e . o r g ’ , ’ u s e r ’ , ’ p a s s ’ ) , 8 $ l o g g e r = new L o g g e r ( 9 new L o g g i n g D i s p a t c h e r (10 array (11 new S y s l o g L o g g e r ( ) ,12 new F i l e S y s t e m L o g g e r ( ’ l o g / e r r o r s . l o g ’ )13 )14 )15 )16 )17 ),18 $logger19 );
  42. 42. Advanced OO Patterns 15 / 44 Injecting dependencies 1 <?php 2 3 $ m e s s e n g e r = new M e s s a g e D i s p a t c h e r ( 4 array ( 5 new J a b b e r M e s s e n g e r ( ’ j a b b e r . e x a m p l e . o r g ’ , ’ u s e r ’ , ’ p a s s ’ ) , 6 new M a i l M e s s e n g e r ( 7 new M a i l S m t p T r a n s p o r t ( ’ m a i l . e x a m p l e . o r g ’ , ’ u s e r ’ , ’ p a s s ’ ) , 8 $ l o g g e r = new L o g g e r ( 9 new L o g g i n g D i s p a t c h e r (10 array (11 new S y s l o g L o g g e r ( ) ,12 new F i l e S y s t e m L o g g e r ( ’ l o g / e r r o r s . l o g ’ )13 )14 )15 )16 )17 ),18 $logger19 );
  43. 43. Advanced OO Patterns 15 / 44 Injecting dependencies 1 <?php 2 3 $ m e s s e n g e r = new M e s s a g e D i s p a t c h e r ( 4 array ( 5 new J a b b e r M e s s e n g e r ( ’ j a b b e r . e x a m p l e . o r g ’ , ’ u s e r ’ , ’ p a s s ’ ) , 6 new M a i l M e s s e n g e r ( 7 new M a i l S m t p T r a n s p o r t ( ’ m a i l . e x a m p l e . o r g ’ , ’ u s e r ’ , ’ p a s s ’ ) , 8 $ l o g g e r = new L o g g e r ( 9 new L o g g i n g D i s p a t c h e r (10 array (11 new S y s l o g L o g g e r ( ) ,12 new F i l e S y s t e m L o g g e r ( ’ l o g / e r r o r s . l o g ’ )13 )14 )15 )16 )17 ),18 $logger19 );
  44. 44. Advanced OO Patterns 15 / 44 Injecting dependencies 1 <?php 2 3 $ m e s s e n g e r = new M e s s a g e D i s p a t c h e r ( 4 array ( 5 new J a b b e r M e s s e n g e r ( ’ j a b b e r . e x a m p l e . o r g ’ , ’ u s e r ’ , ’ p a s s ’ ) , 6 new M a i l M e s s e n g e r ( 7 new M a i l S m t p T r a n s p o r t ( ’ m a i l . e x a m p l e . o r g ’ , ’ u s e r ’ , ’ p a s s ’ ) , 8 $ l o g g e r = new L o g g e r ( 9 new L o g g i n g D i s p a t c h e r (10 array (11 new S y s l o g L o g g e r ( ) ,12 new F i l e S y s t e m L o g g e r ( ’ l o g / e r r o r s . l o g ’ )13 )14 )15 )16 )17 ),18 $logger19 );
  45. 45. Advanced OO Patterns 15 / 44 Injecting dependencies 1 <?php 2 3 $ m e s s e n g e r = new M e s s a g e D i s p a t c h e r ( 4 array ( 5 new J a b b e r M e s s e n g e r ( ’ j a b b e r . e x a m p l e . o r g ’ , ’ u s e r ’ , ’ p a s s ’ ) , 6 new M a i l M e s s e n g e r ( 7 new M a i l S m t p T r a n s p o r t ( ’ m a i l . e x a m p l e . o r g ’ , ’ u s e r ’ , ’ p a s s ’ ) , 8 $ l o g g e r = new L o g g e r ( 9 new L o g g i n g D i s p a t c h e r (10 array (11 new S y s l o g L o g g e r ( ) ,12 new F i l e S y s t e m L o g g e r ( ’ l o g / e r r o r s . l o g ’ )13 )14 )15 )16 )17 ),18 $logger19 );
  46. 46. Advanced OO Patterns 15 / 44 Injecting dependencies 1 <?php 2 3 $ m e s s e n g e r = new M e s s a g e D i s p a t c h e r ( 4 array ( 5 new J a b b e r M e s s e n g e r ( ’ j a b b e r . e x a m p l e . o r g ’ , ’ u s e r ’ , ’ p a s s ’ ) , 6 new M a i l M e s s e n g e r ( 7 new M a i l S m t p T r a n s p o r t ( ’ m a i l . e x a m p l e . o r g ’ , ’ u s e r ’ , ’ p a s s ’ ) , 8 $ l o g g e r = new L o g g e r ( 9 new L o g g i n g D i s p a t c h e r (10 array (11 new S y s l o g L o g g e r ( ) ,12 new F i l e S y s t e m L o g g e r ( ’ l o g / e r r o r s . l o g ’ )13 )14 )15 )16 )17 ),18 $logger19 );
  47. 47. Advanced OO Patterns 16 / 44 What is desired? Don’t have ctors all over the place Manage dependencies Replace dependencies fine grained Lazy initialization
  48. 48. Advanced OO Patterns 17 / 44 The Arbit DIC Exemplary for a high-end DIC Shared objects (initialized once) Closures for lazy initialization Inherent dependency resolution Base class for custom DICs Heavy use of interceptors No implementation details, see here: http://bit.ly/arbitDIC
  49. 49. Advanced OO Patterns 17 / 44 The Arbit DIC Exemplary for a high-end DIC Shared objects (initialized once) Closures for lazy initialization Inherent dependency resolution Base class for custom DICs Heavy use of interceptors No implementation details, see here: http://bit.ly/arbitDIC
  50. 50. Advanced OO Patterns 17 / 44 The Arbit DIC Exemplary for a high-end DIC Shared objects (initialized once) Closures for lazy initialization Inherent dependency resolution Base class for custom DICs Heavy use of interceptors No implementation details, see here: http://bit.ly/arbitDIC
  51. 51. Advanced OO Patterns 17 / 44 The Arbit DIC Exemplary for a high-end DIC Shared objects (initialized once) Closures for lazy initialization Inherent dependency resolution Base class for custom DICs Heavy use of interceptors No implementation details, see here: http://bit.ly/arbitDIC
  52. 52. Advanced OO Patterns 18 / 44 Managing dependencies 3 c l a s s arbitEnvironmentDIC extends arbitDependencyInjectionContainer 4 {13 public function i n i t i a l i z e ()14 {38 }39 }
  53. 53. Advanced OO Patterns 18 / 44 Managing dependencies 3 c l a s s arbitEnvironmentDIC extends arbitDependencyInjectionContainer 4 {13 public function i n i t i a l i z e ()14 {38 }39 }
  54. 54. Advanced OO Patterns 19 / 44 Managing dependencies 3 c l a s s arbitEnvironmentDIC extends arbitDependencyInjectionContainer 4 {13 public function i n i t i a l i z e ()14 {15 $this− ache = f u n c t i o n ( $dic ) >c16 {17 r e t u r n new a r b i t F i l e s y s t e m C a c h e ( $ d i c− e q u e s t − o n t r o l l e r ) ; >r >c18 };38 }39 }
  55. 55. Advanced OO Patterns 20 / 44 Managing dependencies 3 c l a s s arbitEnvironmentDIC extends arbitDependencyInjectionContainer 4 {13 public function i n i t i a l i z e ()14 {20 $this− >m e s s e n g e r = f u n c t i o n ( $ d i c )21 {22 r e t u r n new a r b i t M e s s e n g e r ( a r r a y (23 ’ e m a i l ’ = $ d i c− > >m a i l M e s s e n g e r ,24 ) );25 };38 }39 }
  56. 56. Advanced OO Patterns 21 / 44 Managing dependencies 3 c l a s s arbitEnvironmentDIC extends arbitDependencyInjectionContainer 4 {13 public function i n i t i a l i z e ()14 {27 $this− >m a i l M e s s e n g e r = f u n c t i o n ( $ d i c )28 {29 r e t u r n new a r b i t M a i l M e s s e n g e r (30 $ d i c−>m a i l T r a n s p o r t ,31 $ d i c− o n f i g u r a t i o n − >c >main ,32 $ d i c− o n f i g u r a t i o n − r o j e c t ( $ d i c− e q u e s t − o n t r o l l e r ) , >c >p >r >c33 $ d i c− i e w s− e c o r a t o r >v >d34 );35 };38 }39 }
  57. 57. Advanced OO Patterns 22 / 44 Dependency Injection Approaches Constructor injection We just saw that Setter injection Use set*() Default instances? Interface injection Specific to some containers
  58. 58. Advanced OO Patterns 22 / 44 Dependency Injection Approaches Constructor injection We just saw that Setter injection Use set*() Default instances? Interface injection Specific to some containers
  59. 59. Advanced OO Patterns 22 / 44 Dependency Injection Approaches Constructor injection We just saw that Setter injection Use set*() Default instances? Interface injection Specific to some containers
  60. 60. Advanced OO Patterns 23 / 44 More about DIC Phemto - A dependency injector for PHP 5 http://phemto.sourceforge.net/ Pimple - A small PHP 5.3 dependency injection container https://github.com/fabpot/Pimple Bucket - Basic di-container for php https://github.com/troelskn/bucket Symfony Dependency Injection http://components.symfony-project.org/ dependency-injection/ Martin Fowler on Dependency Injection http://martinfowler.com/articles/injection.html
  61. 61. Advanced OO Patterns 23 / 44 More about DIC Phemto - A dependency injector for PHP 5 http://phemto.sourceforge.net/ Pimple - A small PHP 5.3 dependency injection container https://github.com/fabpot/Pimple Bucket - Basic di-container for php https://github.com/troelskn/bucket Symfony Dependency Injection http://components.symfony-project.org/ dependency-injection/ Martin Fowler on Dependency Injection http://martinfowler.com/articles/injection.html
  62. 62. Advanced OO Patterns 24 / 44 Outline Introduction Lazy Initialization Dependency Injection Service Locator Data Storage
  63. 63. Advanced OO Patterns 25 / 44 Service Locator Object to retrieve a Service from Deliver locator instead of service directly Basically saves constructor parameters
  64. 64. Advanced OO Patterns 25 / 44 Service Locator Object to retrieve a Service from Deliver locator instead of service directly Basically saves constructor parameters
  65. 65. Advanced OO Patterns 26 / 44 Service Locator 1 <?php 2 3 c l a s s MessageServiceLocator 4 { 5 public function c o n s t r u c t ( array $messengers , Logger $ l o g g e r ) 6 { /∗ . . . ∗/ } 7 8 public function getMessengers () 9 { /∗ . . . ∗/ }1011 public function getLogger ()12 { /∗ . . . ∗/ }13 }1415 c l a s s MessageDispatcher16 {17 public function construct ( MessageServiceLocator $serviceLoc )18 { /∗ . . . ∗/ }19 }2021 ?>
  66. 66. Advanced OO Patterns 26 / 44 Service Locator 1 <?php 2 3 c l a s s MessageServiceLocator 4 { 5 public function c o n s t r u c t ( array $messengers , Logger $ l o g g e r ) 6 { /∗ . . . ∗/ } 7 8 public function getMessengers () 9 { /∗ . . . ∗/ }1011 public function getLogger ()12 { /∗ . . . ∗/ }13 }1415 c l a s s MessageDispatcher16 {17 public function construct ( MessageServiceLocator $serviceLoc )18 { /∗ . . . ∗/ }19 }2021 ?>
  67. 67. Advanced OO Patterns 26 / 44 Service Locator 1 <?php 2 3 c l a s s MessageServiceLocator 4 { 5 public function c o n s t r u c t ( array $messengers , Logger $ l o g g e r ) 6 { /∗ . . . ∗/ } 7 8 public function getMessengers () 9 { /∗ . . . ∗/ }1011 public function getLogger ()12 { /∗ . . . ∗/ }13 }1415 c l a s s MessageDispatcher16 {17 public function construct ( MessageServiceLocator $serviceLoc )18 { /∗ . . . ∗/ }19 }2021 ?>
  68. 68. Advanced OO Patterns 26 / 44 Service Locator 1 <?php 2 3 c l a s s MessageServiceLocator 4 { 5 public function c o n s t r u c t ( array $messengers , Logger $ l o g g e r ) 6 { /∗ . . . ∗/ } 7 8 public function getMessengers () 9 { /∗ . . . ∗/ }1011 public function getLogger ()12 { /∗ . . . ∗/ }13 }1415 c l a s s MessageDispatcher16 {17 public function construct ( MessageServiceLocator $serviceLoc )18 { /∗ . . . ∗/ }19 }2021 ?>
  69. 69. Advanced OO Patterns 27 / 44 Pattern purism DIC vs. Service Locator
  70. 70. Advanced OO Patterns 28 / 44 Outline Introduction Lazy Initialization Dependency Injection Service Locator Data Storage
  71. 71. Advanced OO Patterns 29 / 44 The situation Model (application) Storage
  72. 72. Advanced OO Patterns 29 / 44 The situation Model (application) Storage store restore
  73. 73. Advanced OO Patterns 30 / 44 Challenges Model and storage structure differ Object relational impedance mismatch Different access approaches Query language differences Storage back end might change Back ends could even be mixed ...
  74. 74. Advanced OO Patterns 30 / 44 Challenges Model and storage structure differ Object relational impedance mismatch Different access approaches Query language differences Storage back end might change Back ends could even be mixed ...
  75. 75. Advanced OO Patterns 30 / 44 Challenges Model and storage structure differ Object relational impedance mismatch Different access approaches Query language differences Storage back end might change Back ends could even be mixed ...
  76. 76. Advanced OO Patterns 30 / 44 Challenges Model and storage structure differ Object relational impedance mismatch Different access approaches Query language differences Storage back end might change Back ends could even be mixed ...
  77. 77. Advanced OO Patterns 30 / 44 Challenges Model and storage structure differ Object relational impedance mismatch Different access approaches Query language differences Storage back end might change Back ends could even be mixed ...
  78. 78. Advanced OO Patterns 30 / 44 Challenges Model and storage structure differ Object relational impedance mismatch Different access approaches Query language differences Storage back end might change Back ends could even be mixed ...
  79. 79. Advanced OO Patterns 30 / 44 Challenges Model and storage structure differ Object relational impedance mismatch Different access approaches Query language differences Storage back end might change Back ends could even be mixed ...
  80. 80. Advanced OO Patterns 31 / 44 Active Record 1 <?php 2 3 class Invoice extends ActiveRecord 4 { 5 protected $id ; 6 protected $positions ; 7 protected $vat ; 8 // . . . 910 public function calculateValue ()11 { /∗ b u s i n e s s l o g i c ∗/ }12 }1314 c l a s s ActiveRecord15 {16 public function i n s e r t ()17 { /∗ . . . ∗/ }18 p u b l i c f u n c t i o n update ()19 { /∗ . . . ∗/ }20 }
  81. 81. Advanced OO Patterns 31 / 44 Active Record 1 <?php 2 3 class Invoice extends ActiveRecord 4 { 5 protected $id ; 6 protected $positions ; 7 protected $vat ; 8 // . . . 910 public function calculateValue ()11 { /∗ b u s i n e s s l o g i c ∗/ }12 }1314 c l a s s ActiveRecord15 {16 public function i n s e r t ()17 { /∗ . . . ∗/ }18 p u b l i c f u n c t i o n update ()19 { /∗ . . . ∗/ }20 }
  82. 82. Advanced OO Patterns 31 / 44 Active Record 1 <?php 2 3 class Invoice extends ActiveRecord 4 { 5 protected $id ; 6 protected $positions ; 7 protected $vat ; 8 // . . . 910 public function calculateValue ()11 { /∗ b u s i n e s s l o g i c ∗/ }12 }1314 c l a s s ActiveRecord15 {16 public function i n s e r t ()17 { /∗ . . . ∗/ }18 p u b l i c f u n c t i o n update ()19 { /∗ . . . ∗/ }20 }
  83. 83. Advanced OO Patterns 31 / 44 Active Record 1 <?php 2 3 class Invoice extends ActiveRecord 4 { 5 protected $id ; 6 protected $positions ; 7 protected $vat ; 8 // . . . 910 public function calculateValue ()11 { /∗ b u s i n e s s l o g i c ∗/ }12 }1314 c l a s s ActiveRecord15 {16 public function i n s e r t ()17 { /∗ . . . ∗/ }18 p u b l i c f u n c t i o n update ()19 { /∗ . . . ∗/ }20 }
  84. 84. Advanced OO Patterns 32 / 44 Active Record Combines storage and business logic Commonly storage logic in base class Model class corresponds to database record
  85. 85. Advanced OO Patterns 33 / 44 Evaluation Pros Cons Very easy to use Model structure = storage Very few code to structure write Classes become complex Business logic Storage logic Broken object semantics Changes ripple over Hard to exchange storage logic Really hard to test!
  86. 86. Advanced OO Patterns 33 / 44 Evaluation Pros Cons Very easy to use Model structure = storage Very few code to structure write Classes become complex Business logic Storage logic Broken object semantics Changes ripple over Hard to exchange storage logic Really hard to test!
  87. 87. Advanced OO Patterns 33 / 44 Evaluation Pros Cons Very easy to use Model structure = storage Very few code to structure write Classes become complex Business logic Storage logic Broken object semantics Changes ripple over Hard to exchange storage logic Really hard to test!
  88. 88. Advanced OO Patterns 33 / 44 Evaluation Pros Cons Very easy to use Model structure = storage Very few code to structure write Classes become complex Business logic Storage logic Broken object semantics Changes ripple over Hard to exchange storage logic Really hard to test!
  89. 89. Advanced OO Patterns 33 / 44 Evaluation Pros Cons Very easy to use Model structure = storage Very few code to structure write Classes become complex Business logic Storage logic Broken object semantics Changes ripple over Hard to exchange storage logic Really hard to test!
  90. 90. Advanced OO Patterns 33 / 44 Evaluation Pros Cons Very easy to use Model structure = storage Very few code to structure write Classes become complex Business logic Storage logic Broken object semantics Changes ripple over Hard to exchange storage logic Really hard to test!
  91. 91. Advanced OO Patterns 33 / 44 Evaluation Pros Cons Very easy to use Model structure = storage Very few code to structure write Classes become complex Business logic Storage logic Broken object semantics Changes ripple over Hard to exchange storage logic Really hard to test!
  92. 92. Advanced OO Patterns 33 / 44 Evaluation Pros Cons Very easy to use Model structure = storage Very few code to structure write Classes become complex Business logic Storage logic Broken object semantics Changes ripple over Hard to exchange storage logic Really hard to test!
  93. 93. Advanced OO Patterns 34 / 44 Lesson learned . . . De-couple business and storage logic!
  94. 94. Advanced OO Patterns 35 / 44 Row Data Gateway 1 <?php 2 3 class Invoice 4 { 5 p r o t e c t e d $data ; 6 // . . . 7 8 public function c o n s t r u c t ( InvoiceGateway $data ) 9 { $this− ata = $data ; } >d1011 public function calculateValue ()12 { /∗ b u s i n e s s l o g i c ∗/ }13 }1415 c l a s s InvoiceGateway16 {17 protected $id ;18 protected $positions ;19 protected $vat ;2021 public function i n s e r t ()22 { /∗ . . . ∗/ }23 p u b l i c f u n c t i o n update ()24 { /∗ . . . ∗/ }25 }
  95. 95. Advanced OO Patterns 35 / 44 Row Data Gateway 1 <?php 2 3 class Invoice 4 { 5 p r o t e c t e d $data ; 6 // . . . 7 8 public function c o n s t r u c t ( InvoiceGateway $data ) 9 { $this− ata = $data ; } >d1011 public function calculateValue ()12 { /∗ b u s i n e s s l o g i c ∗/ }13 }1415 c l a s s InvoiceGateway16 {17 protected $id ;18 protected $positions ;19 protected $vat ;2021 public function i n s e r t ()22 { /∗ . . . ∗/ }23 p u b l i c f u n c t i o n update ()24 { /∗ . . . ∗/ }25 }
  96. 96. Advanced OO Patterns 35 / 44 Row Data Gateway 1 <?php 2 3 class Invoice 4 { 5 p r o t e c t e d $data ; 6 // . . . 7 8 public function c o n s t r u c t ( InvoiceGateway $data ) 9 { $this− ata = $data ; } >d1011 public function calculateValue ()12 { /∗ b u s i n e s s l o g i c ∗/ }13 }1415 c l a s s InvoiceGateway16 {17 protected $id ;18 protected $positions ;19 protected $vat ;2021 public function i n s e r t ()22 { /∗ . . . ∗/ }23 p u b l i c f u n c t i o n update ()24 { /∗ . . . ∗/ }25 }
  97. 97. Advanced OO Patterns 35 / 44 Row Data Gateway 1 <?php 2 3 class Invoice 4 { 5 p r o t e c t e d $data ; 6 // . . . 7 8 public function c o n s t r u c t ( InvoiceGateway $data ) 9 { $this− ata = $data ; } >d1011 public function calculateValue ()12 { /∗ b u s i n e s s l o g i c ∗/ }13 }1415 c l a s s InvoiceGateway16 {17 protected $id ;18 protected $positions ;19 protected $vat ;2021 public function i n s e r t ()22 { /∗ . . . ∗/ }23 p u b l i c f u n c t i o n update ()24 { /∗ . . . ∗/ }25 }
  98. 98. Advanced OO Patterns 36 / 44 Row Data Gateway Decouples storage from business logic Still convenient OO interface for storage Still some objects coupled to storage (Table Data Gateway is a somewhat similar approach)
  99. 99. Advanced OO Patterns 36 / 44 Row Data Gateway Decouples storage from business logic Still convenient OO interface for storage Still some objects coupled to storage (Table Data Gateway is a somewhat similar approach)
  100. 100. Advanced OO Patterns 37 / 44 Evaluation Pros Cons Easy to use Some objects model DB Few code to write structure Gateways can be Changes still ripple over generated Still hard to exchange Easier to test storage logic
  101. 101. Advanced OO Patterns 37 / 44 Evaluation Pros Cons Easy to use Some objects model DB Few code to write structure Gateways can be Changes still ripple over generated Still hard to exchange Easier to test storage logic
  102. 102. Advanced OO Patterns 37 / 44 Evaluation Pros Cons Easy to use Some objects model DB Few code to write structure Gateways can be Changes still ripple over generated Still hard to exchange Easier to test storage logic
  103. 103. Advanced OO Patterns 37 / 44 Evaluation Pros Cons Easy to use Some objects model DB Few code to write structure Gateways can be Changes still ripple over generated Still hard to exchange Easier to test storage logic
  104. 104. Advanced OO Patterns 37 / 44 Evaluation Pros Cons Easy to use Some objects model DB Few code to write structure Gateways can be Changes still ripple over generated Still hard to exchange Easier to test storage logic
  105. 105. Advanced OO Patterns 38 / 44 Data Mapper 1 <?php 2 3 class Invoice 4 { 5 protected $positions ; 6 protected $vat ; 7 // . . . 8 9 public function calculateValue ()10 { /∗ b u s i n e s s l o g i c ∗/ }11 }1213 interface InvoiceMapper14 {15 public function store ( Invoice $invoice ) ;16 public f u n c t i o n update ( I n v o i c e $ i n v o i c e ) ;17 public f u n c t i o n f i n d B y C u s t o m e r ( Customer $ c u s t o m e r ) ;18 }1920 c l a s s DbInvoiceMapper implements InvoiceMapper21 {22 // . . .23 }2425 ?>
  106. 106. Advanced OO Patterns 38 / 44 Data Mapper 1 <?php 2 3 class Invoice 4 { 5 protected $positions ; 6 protected $vat ; 7 // . . . 8 9 public function calculateValue ()10 { /∗ b u s i n e s s l o g i c ∗/ }11 }1213 interface InvoiceMapper14 {15 public function store ( Invoice $invoice ) ;16 public f u n c t i o n update ( I n v o i c e $ i n v o i c e ) ;17 public f u n c t i o n f i n d B y C u s t o m e r ( Customer $ c u s t o m e r ) ;18 }1920 c l a s s DbInvoiceMapper implements InvoiceMapper21 {22 // . . .23 }2425 ?>
  107. 107. Advanced OO Patterns 38 / 44 Data Mapper 1 <?php 2 3 class Invoice 4 { 5 protected $positions ; 6 protected $vat ; 7 // . . . 8 9 public function calculateValue ()10 { /∗ b u s i n e s s l o g i c ∗/ }11 }1213 interface InvoiceMapper14 {15 public function store ( Invoice $invoice ) ;16 public f u n c t i o n update ( I n v o i c e $ i n v o i c e ) ;17 public f u n c t i o n f i n d B y C u s t o m e r ( Customer $ c u s t o m e r ) ;18 }1920 c l a s s DbInvoiceMapper implements InvoiceMapper21 {22 // . . .23 }2425 ?>
  108. 108. Advanced OO Patterns 38 / 44 Data Mapper 1 <?php 2 3 class Invoice 4 { 5 protected $positions ; 6 protected $vat ; 7 // . . . 8 9 public function calculateValue ()10 { /∗ b u s i n e s s l o g i c ∗/ }11 }1213 interface InvoiceMapper14 {15 public function store ( Invoice $invoice ) ;16 public f u n c t i o n update ( I n v o i c e $ i n v o i c e ) ;17 public f u n c t i o n f i n d B y C u s t o m e r ( Customer $ c u s t o m e r ) ;18 }1920 c l a s s DbInvoiceMapper implements InvoiceMapper21 {22 // . . .23 }2425 ?>
  109. 109. Advanced OO Patterns 39 / 44 Data Mapper Decouple storage from model No OO modelling of DB structure Model does not even know a database exists
  110. 110. Advanced OO Patterns 40 / 44 Evaluation Pros Cons Complete decoupling Quite some code Model is not aware of storage to write Clean storage interface Mapping can Implement different storages! become complex DB changes only affect mapping layer Model changes only affect mapping layer Nice for testing
  111. 111. Advanced OO Patterns 40 / 44 Evaluation Pros Cons Complete decoupling Quite some code Model is not aware of storage to write Clean storage interface Mapping can Implement different storages! become complex DB changes only affect mapping layer Model changes only affect mapping layer Nice for testing
  112. 112. Advanced OO Patterns 40 / 44 Evaluation Pros Cons Complete decoupling Quite some code Model is not aware of storage to write Clean storage interface Mapping can Implement different storages! become complex DB changes only affect mapping layer Model changes only affect mapping layer Nice for testing
  113. 113. Advanced OO Patterns 40 / 44 Evaluation Pros Cons Complete decoupling Quite some code Model is not aware of storage to write Clean storage interface Mapping can Implement different storages! become complex DB changes only affect mapping layer Model changes only affect mapping layer Nice for testing
  114. 114. Advanced OO Patterns 40 / 44 Evaluation Pros Cons Complete decoupling Quite some code Model is not aware of storage to write Clean storage interface Mapping can Implement different storages! become complex DB changes only affect mapping layer Model changes only affect mapping layer Nice for testing
  115. 115. Advanced OO Patterns 40 / 44 Evaluation Pros Cons Complete decoupling Quite some code Model is not aware of storage to write Clean storage interface Mapping can Implement different storages! become complex DB changes only affect mapping layer Model changes only affect mapping layer Nice for testing
  116. 116. Advanced OO Patterns 40 / 44 Evaluation Pros Cons Complete decoupling Quite some code Model is not aware of storage to write Clean storage interface Mapping can Implement different storages! become complex DB changes only affect mapping layer Model changes only affect mapping layer Nice for testing
  117. 117. Advanced OO Patterns 40 / 44 Evaluation Pros Cons Complete decoupling Quite some code Model is not aware of storage to write Clean storage interface Mapping can Implement different storages! become complex DB changes only affect mapping layer Model changes only affect mapping layer Nice for testing
  118. 118. Advanced OO Patterns 41 / 44 Attribution Large parts of this talk are inspired by Patterns of Enterprise Application Architecture by Martin Fowler ISBN 978-0321127426 — http://amzn.to/PofEAA Highy recommended!
  119. 119. Advanced OO Patterns 42 / 44 Conclusion Patterns are not the holy grail! They assign names to good ideas They help you to talk about concepts They can inspire you
  120. 120. Advanced OO Patterns 42 / 44 Conclusion Patterns are not the holy grail! They assign names to good ideas They help you to talk about concepts They can inspire you
  121. 121. Advanced OO Patterns 43 / 44 Q/A Are there any questions left?
  122. 122. Advanced OO Patterns 44 / 44 Thanks for listening Please rate this talk at http://joind.in/2774 and / or give me some feedback right now!
  123. 123. Advanced OO Patterns 44 / 44 Thanks for listening Please rate this talk at http://joind.in/2774 and / or give me some feedback right now! This is very important for . . . Speakers Organizers You!
  124. 124. Advanced OO Patterns 44 / 44 Thanks for listening Please rate this talk at http://joind.in/2774 and / or give me some feedback right now! Stay in touch Tobias Schlitt toby@qafoo.com @tobySen / @qafoo Rent a PHP quality expert: http://qafoo.com
  1. A particular slide catching your eye?

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

×