Is Your Code Too SOLID?

Is Your Code Too SOLID?

This version does NOT include a talk transcript; version with transcript is here:
https://speakerdeck.com/sarahmei/is-your-code-too-solid-with-transcript

SOLID is a collection of five common object-oriented development principles collected into one handy acronym. Smart people recommend learning about it, and even the name sounds fantastic — who doesn’t want to write “solid” code? Clearly, you should strive to follow all five principles, all the time, in all of your code. Right? Well. Good object-oriented design is indeed helpful, but SOLID as a set of guiding principles really isn’t. Let’s break SOLID down and reveal the limitations of our current approach, and try to understand just how SOLID our code needs to be.

92497f51734ed56687928d5fd68d870a?s=128

sarahmei

July 23, 2015
Tweet

Transcript

  1. S A R A H M E I W D

    C N Z 2 0 1 5 I S Y O U R C O D E TO O S O L I D ? https://www.flickr.com/photos/pie4dan/4567311801
  2. DevMynd S A R A H M E I C

    H I E F C O N S U LTA N T D E V M Y N D U N I T E D S TAT E S C H I E F O F BA L D E A G L E S A N D F R E E D O M http://world-map1.org/map1520769_0_0.htm http://www.coolholidaygraphics.com/flagday/glittergraphics/flagdayglitter2.gif https://www.devmynd.com/images/team/sarah-mei-cutout.png
  3. DevMynd

  4. C O D E BA S E S I WO

    R K O N N O R M A L C O D E BA S E S https://www.flickr.com/photos/pmarkham/5361277692
  5. AT F I R S T https://www.flickr.com/photos/jakerust/16661140289/

  6. https://www.flickr.com/photos/123638374@N08/14184697490

  7. https://www.flickr.com/photos/123638374@N08/14184697490

  8. DevMynd https://twitter.com/tenderlove/status/573907559871971328

  9. DevMynd https://twitter.com/tenderlove/status/573907559871971328

  10. DevMynd S A N D I M E T Z

    E X P E RT AT E V E RY T H I N G S E R I O U S LY, G E T I T A M A Z I N G B O O K http://www.sandimetz.com/ http://www.poodr.com/
  11. DevMynd S A N D I M E T Z

    E X P E RT AT E V E RY T H I N G S E R I O U S LY, G E T I T A M A Z I N G B O O K http://www.sandimetz.com/ http://www.poodr.com/
  12. D E S I G N D E C I

    D I N G H OW TO A R R A N G E C O D E https://www.flickr.com/photos/matley0/3616669592
  13. D E S I G N D E C I

    D I N G H OW TO A R R A N G E C O D E https://www.flickr.com/photos/matley0/3616669592
  14. O B J E C T- O R I E

    N T E D D E S I G N G R O U P I N G R E L AT E D F U N C T I O N A L I T Y I N O B J E C T S https://www.flickr.com/photos/mwanasimba/2901201955/
  15. DevMynd A L A N G UA G E F

    E AT U R E A WAY O F T H I N K I N G O B J E C T- O R I E N T E D D E S I G N I S https://www.flickr.com/photos/56627607@N05/15635620289/
  16. DevMynd A L A N G UA G E F

    E AT U R E A WAY O F T H I N K I N G O B J E C T- O R I E N T E D D E S I G N I S A D E S T I N AT I O N A M E A N S TO A N E N D https://www.flickr.com/photos/56627607@N05/15635620289/
  17. https://www.flickr.com/photos/redvers/532076662/

  18. https://www.flickr.com/photos/redvers/532076662/

  19. H I G H L OW H I G H

    L OW C O S T O F U N D E R S TA N D I N G C O S T O F C H A N G E
  20. H I G H L OW H I G H

    L OW C O S T O F U N D E R S TA N D I N G C O S T O F C H A N G E
  21. H I G H L OW H I G H

    L OW Procedures C O S T O F U N D E R S TA N D I N G C O S T O F C H A N G E
  22. H I G H L OW H I G H

    L OW Procedures C O S T O F U N D E R S TA N D I N G C O S T O F C H A N G E
  23. CalendarParamMgr GetCalendarIndex CalendarRouteResolver CalendarRouteResolverFactory RouteResolver RouteReceiver

  24. H I G H L OW H I G H

    L OW Procedures Set of Small Objects C O S T O F U N D E R S TA N D I N G C O S T O F C H A N G E
  25. H I G H L OW H I G H

    L OW Procedures ⚠⚡ Set of Small Objects C O S T O F U N D E R S TA N D I N G C O S T O F C H A N G E
  26. H I G H L OW H I G H

    L OW Procedures Set of Small Objects C O S T O F U N D E R S TA N D I N G C O S T O F C H A N G E Really big objects
  27. H I G H L OW H I G H

    L OW Procedures Set of Small Objects C O S T O F U N D E R S TA N D I N G C O S T O F C H A N G E Really big objects The wrong set of small objects
  28. H I G H L OW H I G H

    Procedures Set of Small Objects L OW C O S T O F U N D E R S TA N D I N G C O S T O F C H A N G E Really big objects The wrong set of small objects
  29. H I G H L OW H I G H

    Procedures Set of Small Objects L OW C O S T O F U N D E R S TA N D I N G C O S T O F C H A N G E Really big objects The wrong set of small objects
  30. PAT T E R N S https://www.flickr.com/photos/dakluza/6665460621

  31. O B S E R V E R N E

    W E M A I L User
  32. O B S E R V E R User UserObserver

  33. O B S E R V E R User UserObserver

    ! E M A I L N E W
  34. H I G H L OW H I G H

    L OW E A S I E R TO C H A N G E H A R D E R TO U N D E R S TA N D C O S T O F U N D E R S TA N D I N G C O S T O F C H A N G E
  35. https://www.flickr.com/photos/betsyweber/5902421276

  36. https://www.flickr.com/photos/grungetextures/4162992874

  37. S O L I D https://www.flickr.com/photos/chrisjfry/309574260/

  38. N A M E S U M M A RY

    U T I L I T Y S O L I D
  39. S I N G L E R E S P

    O N S I B I L I T Y P R I N C I P L E S O L I D https://www.flickr.com/photos/shenamt/8582808329/
  40. N A M E S U M M A RY

    U T I L I T Y S S I N G L E R E S P O N S I B I L I T Y O N E R E S P O N S I B I L I T Y P E R C L A S S M E D O L I D
  41. N A M E S U M M A RY

    U T I L I T Y S S I N G L E R E S P O N S I B I L I T Y O N E R E S P O N S I B I L I T Y P E R C L A S S M E D O L I D
  42. O P E N / C L O S E

    D P R I N C I P L E S O L I D https://www.flickr.com/photos/28481088@N00/4063800774/
  43. N A M E S U M M A RY

    U T I L I T Y S S I N G L E R E S P O N S I B I L I T Y O N E R E S P O N S I B I L I T Y P E R C L A S S M E D O O P E N / C L O S E D D O N ’ T E D I T C O D E ; A D D N E W C O D E L O W L I D
  44. L I S KOV S U B S T I

    T U T I O N P R I N C I P L E S O L I D https://www.flickr.com/photos/vpickering/14416940341/
  45. DevMynd Let Φ(x) be a property provable about objects x

    of type T. Then Φ(y) should be true for objects y of type S where S is a subtype of T.
  46. L I S KOV S U B S T I

    T U T I O N P R I N C I P L E S O L I D https://www.flickr.com/photos/vpickering/14416940341/
  47. I T ’ S N E V E R TO

    O L AT E TO https://www.flickr.com/photos/wcouch/8578612563/
  48. N A M E S U M M A RY

    U T I L I T Y S S I N G L E R E S P O N S I B I L I T Y O N E R E S P O N S I B I L I T Y P E R C L A S S M E D O O P E N / C L O S E D D O N ’ T E D I T C O D E ; A D D N E W C O D E L O W L L I S K O V S U B S T I T U T I O N I N H E R I TA N C E . I T ’ S A T H I N G . L O W I D
  49. I N T E R FA C E S E

    G R E G AT I O N P R I N C I P L E S O L I D https://www.flickr.com/photos/66126733@N04/8477516123/i
  50. W H Y S E G R E G AT

    E I N T E R FA C E S ? Musician AlbumCreator recordSong editSong mixSong sellMerch playSetList Gig
  51. W H Y S E G R E G AT

    E I N T E R FA C E S ? Musician AlbumCreator recordSong editSong mixSong sellMerch playSetList Gig driveVan
  52. W H Y S E G R E G AT

    E I N T E R FA C E S ? StudioActions AlbumCreator recordSong editSong mixSong sellMerch playSetList Gig driveVan VenueActions
  53. N A M E S U M M A RY

    U T I L I T Y S S I N G L E R E S P O N S I B I L I T Y O N E R E S P O N S I B I L I T Y P E R C L A S S M E D O O P E N / C L O S E D D O N ’ T E D I T C O D E ; A D D N E W C O D E L O W L L I S K O V S U B S T I T U T I O N I N H E R I TA N C E . I T ’ S A T H I N G . L O W I I N T E R FA C E S E G R E G AT I O N M A K E T H E A P I S M A L L H I G H D
  54. D E P E N D E N C Y

    I N V E R S I O N P R I N C I P L E S O L I D https://www.flickr.com/photos/hansmaulwurf/13702053625/
  55. N A M E S U M M A RY

    U T I L I T Y S S I N G L E R E S P O N S I B I L I T Y O N E R E S P O N S I B I L I T Y P E R C L A S S M E D O O P E N / C L O S E D D O N ’ T E D I T C O D E ; A D D N E W C O D E L O W L L I S K O V S U B S T I T U T I O N I N H E R I TA N C E . I T ’ S A T H I N G . L O W I I N T E R FA C E S E G R E G AT I O N M A K E T H E A P I S M A L L H I G H D D E P E N D E N C Y I N V E R S I O N M O V E C H O I C E S T O E D G E S O F S Y S T E M H I G H
  56. N A M E S U M M A RY

    U T I L I T Y S S I N G L E R E S P O N S I B I L I T Y O N E R E S P O N S I B I L I T Y P E R C L A S S M E D O O P E N / C L O S E D D O N ’ T E D I T C O D E ; A D D N E W C O D E L O W L L I S K O V S U B S T I T U T I O N I N H E R I TA N C E . I T ’ S A T H I N G . L O W I I N T E R FA C E S E G R E G AT I O N M A K E T H E A P I S M A L L H I G H D D E P E N D E N C Y I N V E R S I O N M O V E C H O I C E S T O E D G E S O F S Y S T E M H I G H
  57. N A M E S U M M A RY

    U T I L I T Y S S I N G L E R E S P O N S I B I L I T Y O N E R E S P O N S I B I L I T Y P E R C L A S S M E D O O P E N / C L O S E D D O N ’ T E D I T C O D E ; A D D N E W C O D E L O W L L I S K O V S U B S T I T U T I O N I N H E R I TA N C E . I T ’ S A T H I N G . L O W I I N T E R FA C E S E G R E G AT I O N M A K E T H E A P I S M A L L H I G H D D E P E N D E N C Y I N V E R S I O N M O V E C H O I C E S T O E D G E S O F S Y S T E M H I G H
  58. https://www.flickr.com/photos/29295318@N08/19322005453

  59. S T R AT E G Y & TA C

    T I C S https://www.flickr.com/photos/teegardin/6150427712/
  60. \ O / \ O / \ O / G

    OA L : P R O M O U N TA I N E E R S T R AT E G Y: C L I M B T H I S M T N TA C T I C S : T H E R O U T E U P https://www.flickr.com/photos/frenchy/222016256/
  61. \ O / \ O / \ O / G

    OA L : P R O M O U N TA I N E E R S T R AT E G Y: C L I M B T H I S M T N TA C T I C S : T H E R O U T E U P 1 2 3 https://www.flickr.com/photos/frenchy/222016256/
  62. G OA L : P R O M O U

    N TA I N E E R S T R AT E G Y: C L I M B T H I S M T N TA C T I C S : T H E R O U T E U P \ O / https://www.flickr.com/photos/frenchy/222016256/
  63. G OA L : P R O M O U

    N TA I N E E R S T R AT E G Y: C L I M B T H I S M T N https://www.flickr.com/photos/frenchy/222016256/
  64. G OA L : C H A N G E

    A B L E S O F T WA R E S T R AT E G Y: TA C T I C S : O O D E S I G N S O L I D https://www.flickr.com/photos/sunfox/5084875405/
  65. G OA L : C H A N G E

    A B L E S O F T WA R E S T R AT E G Y: TA C T I C S : O O D E S I G N S O L I D https://www.flickr.com/photos/sunfox/5084875405/
  66. N A M E S U M M A RY

    U T I L I T Y S S I N G L E R E S P O N S I B I L I T Y O N E R E S P O N S I B I L I T Y P E R C L A S S M E D O O P E N / C L O S E D D O N ’ T E D I T C O D E ; A D D N E W C O D E L O W L L I S K O V S U B S T I T U T I O N I N H E R I TA N C E . I T ’ S A T H I N G . L O W I I N T E R FA C E S E G R E G AT I O N M A K E T H E A P I S M A L L H I G H D D E P E N D E N C Y I N V E R S I O N M O V E C H O I C E S T O E D G E S O F S Y S T E M H I G H
  67. G OA L : C H A N G E

    A B L E S O F T WA R E S T R AT E G Y: TA C T I C S : S O L I D P R I N C I P L E S https://www.flickr.com/photos/sunfox/5084875405/
  68. G OA L : C H A N G E

    A B L E S O F T WA R E S T R AT E G Y: TA C T I C S : S O L I D P R I N C I P L E S https://www.flickr.com/photos/sunfox/5084875405/
  69. G OA L : C H A N G E

    A B L E S O F T WA R E S T R AT E G Y: TA C T I C S : S O L I D P R I N C I P L E S https://www.flickr.com/photos/sunfox/5084875405/
  70. https://www.flickr.com/photos/jonathancohen/15420956905

  71. H I G H L OW H I G H

    L OW The wrong set of small objects ❗ C O S T O F U N D E R S TA N D I N G C O S T O F C H A N G E
  72. DevMynd T H E O N LY WAY TO M

    A K E A S TO P - T H E - WO R L D R E FA C TO R I N G WO R K I S TO N OT D O I T . http://www.imdb.com/title/tt0086567/
  73. https://www.flickr.com/photos/frenchy/222016256/

  74. https://www.flickr.com/photos/frenchy/222016256/

  75. DevMynd post.comments.first.author.email NOPE

  76. DevMynd https://www.flickr.com/photos/83794824@N07/8059223873/

  77. S TA B L E

  78. S TA B L E

  79. S TA B L E S M E L L

    Y O U R C O D E https://www.flickr.com/photos/pedrosimoes7/169983321/
  80. T I N Y P R O B L E

    M S F I R S T S TA B L E https://www.flickr.com/photos/ian-arlett/13706787684/
  81. S TA B L E https://www.flickr.com/photos/ian-arlett/13706787684/ T I N Y

    P R O B L E M S F I R S T
  82. A U G M E N T T E S

    T S S TA B L E https://www.flickr.com/photos/horiavarlan/4273968004/
  83. https://www.flickr.com/photos/horiavarlan/4273968004/ S TA B L E A U G M

    E N T T E S T S
  84. S TA B L E BA C K U P

    https://www.flickr.com/photos/mjonasson/19228720295/
  85. S TA B L E L E AV E I

    T B E T T E R T H A N Y O U F O U N D I T https://www.flickr.com/photos/spierisf/6989462184/
  86. https://www.flickr.com/photos/spierisf/6989462184/ S TA B L E L E AV E

    I T B E T T E R T H A N Y O U F O U N D I T
  87. https://www.flickr.com/photos/spierisf/6989462184/ S TA B L E L E AV E

    I T B E T T E R T H A N Y O U F O U N D I T
  88. E X P E C T G O O D

    R E A S O N S S TA B L E https://www.flickr.com/photos/an_untrained_eye/5012331537
  89. https://www.flickr.com/photos/an_untrained_eye/5012331537 S TA B L E E X P E

    C T G O O D R E A S O N S
  90. S S M E L L Y O U R

    C O D E T T I N Y P R O B L E M S F I R S T A A U G M E N T T E S T S B B A C K U P L L E AV E I T B E T T E R E E X P E C T G O O D R E A S O N S
  91. S S M E L L Y O U R

    C O D E T T I N Y P R O B L E M S F I R S T A A U G M E N T T E S T S B B A C K U P L L E AV E I T B E T T E R E E X P E C T G O O D R E A S O N S
  92. DevMynd https://twitter.com/kentbeck/status/250733358307500032

  93. DevMynd https://twitter.com/kentbeck/status/250733358307500032

  94. https://www.flickr.com/photos/frenchy/222016256/

  95. \ O / https://www.flickr.com/photos/frenchy/222016256/

  96. https://www.flickr.com/photos/bevrichardmartin/5985876061/ https://www.flickr.com/photos/discarnate/27211024/ https://www.flickr.com/photos/lynardie/16191183291/

  97. DevMynd Sarah Mei sarah@devmynd.com @sarahmei THANK YOU!