Se ha denunciado esta presentación.
Utilizamos tu perfil de LinkedIn y tus datos de actividad para personalizar los anuncios y mostrarte publicidad más relevante. Puedes cambiar tus preferencias de publicidad en cualquier momento.
SOLID Design Principles
What the heck is a principle?
What the heck is a principle?Guideline for creating softwarethat stands up well to iterativedevelopment
What the heck is a principle?Guideline for creating softwarethat stands up well to iterativedevelopmentStatements that can...
What the heck is a principle?Guideline for creating softwarethat stands up well to iterativedevelopmentStatements that can...
Why should I care?
Why should I care?Uncle Bob Martin
Why should I care?Uncle Bob Martin    - Old Dude
Why should I care?Uncle Bob Martin    - Old Dude    - Wrote tons of books
Why should I care?Uncle Bob Martin    - Old Dude    - Wrote tons of books    - Knows a thing or two about     writing soft...
Why should I care?Uncle Bob Martin    - Old Dude    - Wrote tons of books    - Knows a thing or two about     writing soft...
Why should I care?Uncle Bob Martin    - Old Dude    - Wrote tons of books    - Knows a thing or two about     writing soft...
Principles vs. Patterns
Principles vs. PatternsAren’t patterns enough?
Principles vs. PatternsAren’t patterns enough?Who are you?
Principles vs. PatternsAren’t patterns enough?Who are you?SOLID Principles are the basisfor useful patterns
S.O.L.I.D.
S. Single ResponsibilityO.L.I.D.
S. Single ResponsibilityO. Open / ClosedL.I.D.
S. Single ResponsibilityO. Open / ClosedL. Liskov SubstitutionI.D.
S. Single ResponsibilityO. Open / ClosedL. Liskov SubstitutionI. Interface SegregationD.
S. Single ResponsibilityO. Open / ClosedL. Liskov SubstitutionI. Interface SegregationD. Dependency Inversion
Single Responsibility Principle
Single Responsibility Principlean Object should only have one“axis of change”
Single Responsibility Principlean Object should only have one“axis of change”as software requirements shift,refactoring is...
Single Responsibility Principlean Object should only have one“axis of change”as software requirements shift,refactoring is...
Single Responsibility Principle
Single Responsibility Principleanti-pattern: watch out forlarge branching statements
Single Responsibility Principleanti-pattern: watch out forlarge branching statementsfavor method simplicity
Single Responsibility Principleanti-pattern: watch out forlarge branching statementsfavor method simplicityshould be appar...
Open/Closed Principle
Open/Closed Principle“[objects] should be open forextension, but closed formodification”
Open/Closed Principle“[objects] should be open forextension, but closed formodification”makes code that’s more resilientov...
Open/Closed Principle“[objects] should be open forextension, but closed formodification”makes code that’s more resilientov...
Open/Closed Principle
Open/Closed Principleanti-pattern: modifying nativePrototypes in Javascript
Open/Closed Principleanti-pattern: modifying nativePrototypes in Javascriptused and violated in Backbone.js
Open/Closed Principleanti-pattern: modifying nativePrototypes in Javascriptused and violated in Backbone.jstest coverage a...
Liskov Substitution
Liskov Substitutionderived types should becompletely substitutable fromtheir base types
Liskov Substitutionderived types should becompletely substitutable fromtheir base typesabout preserving expectations whenc...
Liskov Substitutionderived types should becompletely substitutable fromtheir base typesabout preserving expectations whenc...
Interface Segregation
Interface Segregationfavor many specific interfacesover a single, “fat” interface
Interface Segregationfavor many specific interfacesover a single, “fat” interfacean api should only contains themethods it...
Interface Segregationfavor many specific interfacesover a single, “fat” interfacean api should only contains themethods it...
Interface Segregation
Interface SegregationjQuery is written as a series ofseparate interfaces with acommon core
Interface SegregationjQuery is written as a series ofseparate interfaces with acommon coreincreases performance, sanity
Interface SegregationjQuery is written as a series ofseparate interfaces with acommon coreincreases performance, sanity“no...
Interface SegregationjQuery is written as a series ofseparate interfaces with acommon coreincreases performance, sanity“no...
Dependency Inversion
Dependency Inversion“depend on abstractions, not onconcretions.”
Dependency Inversion“depend on abstractions, not onconcretions.”create high-level software that isdecoupled from low-level...
Dependency Inversion“depend on abstractions, not onconcretions.”create high-level software that isdecoupled from low-level...
Dependency Inversion
Dependency InversionActiveRecord allows Rails toabstract database interface awayfrom users
Dependency InversionActiveRecord allows Rails toabstract database interface awayfrom usersSizzle, $.ajax allows jQuery toa...
What does it mean?
What does it mean?You don’t create re-usable codeby accident.
What does it mean?You don’t create re-usable codeby accident.You experience these principlesevery day
What does it mean?You don’t create re-usable codeby accident.You experience these principlesevery dayCreates a good checkl...
S. Single ResponsibilityO. Open / ClosedL. Liskov SubstitutionI. Interface SegregationD. Dependency Inversion
Próxima SlideShare
Cargando en…5
×

SOLID Design Principles

7.084 visualizaciones

Publicado el

Publicado en: Tecnología
  • Sé el primero en comentar

SOLID Design Principles

  1. 1. SOLID Design Principles
  2. 2. What the heck is a principle?
  3. 3. What the heck is a principle?Guideline for creating softwarethat stands up well to iterativedevelopment
  4. 4. What the heck is a principle?Guideline for creating softwarethat stands up well to iterativedevelopmentStatements that can be madeabout your code’s design
  5. 5. What the heck is a principle?Guideline for creating softwarethat stands up well to iterativedevelopmentStatements that can be madeabout your code’s designFSM avoidance
  6. 6. Why should I care?
  7. 7. Why should I care?Uncle Bob Martin
  8. 8. Why should I care?Uncle Bob Martin - Old Dude
  9. 9. Why should I care?Uncle Bob Martin - Old Dude - Wrote tons of books
  10. 10. Why should I care?Uncle Bob Martin - Old Dude - Wrote tons of books - Knows a thing or two about writing software
  11. 11. Why should I care?Uncle Bob Martin - Old Dude - Wrote tons of books - Knows a thing or two about writing softwareThese things will make youbetter codes
  12. 12. Why should I care?Uncle Bob Martin - Old Dude - Wrote tons of books - Knows a thing or two about writing softwareThese things will make youbetter codes50% less Y U NO!!!
  13. 13. Principles vs. Patterns
  14. 14. Principles vs. PatternsAren’t patterns enough?
  15. 15. Principles vs. PatternsAren’t patterns enough?Who are you?
  16. 16. Principles vs. PatternsAren’t patterns enough?Who are you?SOLID Principles are the basisfor useful patterns
  17. 17. S.O.L.I.D.
  18. 18. S. Single ResponsibilityO.L.I.D.
  19. 19. S. Single ResponsibilityO. Open / ClosedL.I.D.
  20. 20. S. Single ResponsibilityO. Open / ClosedL. Liskov SubstitutionI.D.
  21. 21. S. Single ResponsibilityO. Open / ClosedL. Liskov SubstitutionI. Interface SegregationD.
  22. 22. S. Single ResponsibilityO. Open / ClosedL. Liskov SubstitutionI. Interface SegregationD. Dependency Inversion
  23. 23. Single Responsibility Principle
  24. 24. Single Responsibility Principlean Object should only have one“axis of change”
  25. 25. Single Responsibility Principlean Object should only have one“axis of change”as software requirements shift,refactoring is reflected throughchanges of responsibility in yourcode
  26. 26. Single Responsibility Principlean Object should only have one“axis of change”as software requirements shift,refactoring is reflected throughchanges of responsibility in yourcodecomplex code only gets morecomplex
  27. 27. Single Responsibility Principle
  28. 28. Single Responsibility Principleanti-pattern: watch out forlarge branching statements
  29. 29. Single Responsibility Principleanti-pattern: watch out forlarge branching statementsfavor method simplicity
  30. 30. Single Responsibility Principleanti-pattern: watch out forlarge branching statementsfavor method simplicityshould be apparent when practicingTDD
  31. 31. Open/Closed Principle
  32. 32. Open/Closed Principle“[objects] should be open forextension, but closed formodification”
  33. 33. Open/Closed Principle“[objects] should be open forextension, but closed formodification”makes code that’s more resilientover time
  34. 34. Open/Closed Principle“[objects] should be open forextension, but closed formodification”makes code that’s more resilientover timevery important for maintaininglarge, production codebases
  35. 35. Open/Closed Principle
  36. 36. Open/Closed Principleanti-pattern: modifying nativePrototypes in Javascript
  37. 37. Open/Closed Principleanti-pattern: modifying nativePrototypes in Javascriptused and violated in Backbone.js
  38. 38. Open/Closed Principleanti-pattern: modifying nativePrototypes in Javascriptused and violated in Backbone.jstest coverage alleviates some ofthe pain that open/close want toshield you from
  39. 39. Liskov Substitution
  40. 40. Liskov Substitutionderived types should becompletely substitutable fromtheir base types
  41. 41. Liskov Substitutionderived types should becompletely substitutable fromtheir base typesabout preserving expectations whencreating classes and subclasses
  42. 42. Liskov Substitutionderived types should becompletely substitutable fromtheir base typesabout preserving expectations whencreating classes and subclassesOften this is a built inlanguage feature
  43. 43. Interface Segregation
  44. 44. Interface Segregationfavor many specific interfacesover a single, “fat” interface
  45. 45. Interface Segregationfavor many specific interfacesover a single, “fat” interfacean api should only contains themethods its caller needs
  46. 46. Interface Segregationfavor many specific interfacesover a single, “fat” interfacean api should only contains themethods its caller needsleading cause of FSM, tightlycoupled code
  47. 47. Interface Segregation
  48. 48. Interface SegregationjQuery is written as a series ofseparate interfaces with acommon core
  49. 49. Interface SegregationjQuery is written as a series ofseparate interfaces with acommon coreincreases performance, sanity
  50. 50. Interface SegregationjQuery is written as a series ofseparate interfaces with acommon coreincreases performance, sanity“no client should be forced todepend on code it does not use”
  51. 51. Interface SegregationjQuery is written as a series ofseparate interfaces with acommon coreincreases performance, sanity“no client should be forced todepend on code it does not use”another consequence of TDD
  52. 52. Dependency Inversion
  53. 53. Dependency Inversion“depend on abstractions, not onconcretions.”
  54. 54. Dependency Inversion“depend on abstractions, not onconcretions.”create high-level software that isdecoupled from low-level softwarethrough abstraction
  55. 55. Dependency Inversion“depend on abstractions, not onconcretions.”create high-level software that isdecoupled from low-level softwarethrough abstractionallows for saner, more flexibleresources
  56. 56. Dependency Inversion
  57. 57. Dependency InversionActiveRecord allows Rails toabstract database interface awayfrom users
  58. 58. Dependency InversionActiveRecord allows Rails toabstract database interface awayfrom usersSizzle, $.ajax allows jQuery toabstract low level DOM methods
  59. 59. What does it mean?
  60. 60. What does it mean?You don’t create re-usable codeby accident.
  61. 61. What does it mean?You don’t create re-usable codeby accident.You experience these principlesevery day
  62. 62. What does it mean?You don’t create re-usable codeby accident.You experience these principlesevery dayCreates a good checklist of“objective refactoring” statements
  63. 63. S. Single ResponsibilityO. Open / ClosedL. Liskov SubstitutionI. Interface SegregationD. Dependency Inversion

×