SOLID principles

3,667 views

Published on

Slides from presentation at agiledays09.

Published in: Technology
  • Be the first to comment

SOLID principles

  1. 1. Agile Object Oriented Design SOLID principles [email_address]
  2. 2. Why it is Agile?
  3. 6. ?
  4. 8. principles != rules
  5. 9. Single Responsibility Principle
  6. 10. Problem domain Conceptual model Implementation
  7. 11. Problem domain Conceptual model Implementation ? ?
  8. 13. NOooo!!
  9. 14. Book Instrument 1 * 1 1 Position value: double
  10. 15. Book Position Listener 1 BookPosNode Book Position Listener 2 Network Application position position position
  11. 16. BookPosNode AbstractBookPosNode Subscriber SnapshotProvider HeartbeatMonitor StateMachine
  12. 17. 1
  13. 18. 2
  14. 19. 3
  15. 20. 4 the rest of the class is collapsed
  16. 21. 5 the rest of the class is collapsed
  17. 22. Open/Closed Principle
  18. 23. AbstractPositionNode BookPosNode Client
  19. 24. AbstractPositionNode BookPosNode JMSNode Client PositionWatcher Add Change
  20. 25. AbstractPositionNode BookPosNode JMSNode Client PositionWatcher Add NodeV2
  21. 26. Front-end Back-end Database Change
  22. 27. Liskov Substitution Principle
  23. 31. Ellipse-circle problem rectangle-square
  24. 32. Point x, y : int #equals() #hashCode()
  25. 33. Point x, y : int #equals() #hashCode() ColorPoint color : Color #equals() #hashCode()
  26. 34. Point x, y : int #equals() #hashCode() ColorPoint color : Color #equals() #hashCode() Can't extend like this preserving equals contract (Effective Java, Item 8)
  27. 35. @IViolateLSP
  28. 36. class Dog implements ICanBark … class Button implements IClickable …
  29. 37. Interface Segregation Principle
  30. 38. <<interface>> BigService Client1 Client2 Client3
  31. 39. <<interface>> BigService <<interface>> Service1 <<interface>> Service2 <<interface>> Service3 Client1 Client2 Client3
  32. 41. BookPositionNode <<interface>> ResubscribingNode AbsPosNode StateMachine Client uses uses
  33. 42. Dependency Inversion Principle
  34. 43. Client Service client service
  35. 44. Client <<interface>> Service ServiceImpl client service
  36. 45. client service
  37. 46. Client <<interface>> Service ServiceImpl client service
  38. 47. Client <<interface>> Service ServiceImpl client service
  39. 48. client service
  40. 49. Client <<interface>> Service ServiceImpl client service api
  41. 51. S RP O CP L SP I SP D IP
  42. 52. Single Responsibility Principle
  43. 53. Open/Closed Principle
  44. 54. Liskov Substitution Principle
  45. 55. Interface Segregation Principle
  46. 56. Dependency Inversion Principle
  47. 57. What else?
  48. 58. Problem domain Conceptual model Implementation
  49. 59. F**k Design
  50. 60. Zen Coding
  51. 62. and only then for computers Code is written for people
  52. 63. REP CRP CCP ADP SDP SAP
  53. 64. UML, patterns, and more...
  54. 66. Thanks!
  55. 67. S RP O CP L SP I SP D IP
  56. 68. http://weblogs.java.net/blog/82/2003/09/02/aristotles-error-or-agile-smagile http://blog.objectmentor.com/articles/2009/01/31/quality-doesnt-matter-that-much-jeff-and-joel http://www.codinghorror.com/blog/archives/000805.html http://www.youtube.com/watch?v=2k1uOqRb0HU http://blogs.msdn.com/brada/archive/2003/10/02/50420.aspx http://www.joelonsoftware.com/articles/LeakyAbstractions.html http://www.joelonsoftware.com/items/2009/09/23.html

×