Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Write S.O.L.I.D code

Yoan
June 13, 2017

Write S.O.L.I.D code

Learn how to write Object Oriented S.O.L.I.D code

Yoan

June 13, 2017

Transcript

22 slides
  1. @yot88 bad code / Good code Bad code vs Good

    code Categorize each piece of code
  2. @yot88 Singleton Tight Coupling Untestability Premature Optimization Indescriptive Naming Duplication

    Single Responsibility Open/Closed Principle Liskov Substitution Interface Segregation Dependency Inversion Patterns and anti-patterns
  3. @yot88 Clients should not be forced to depend on methods

    that they do not use. Interface segregation
  4. @yot88 High level modules should not depend on low level

    modules : both should depend on abstractions. DI
  5. @yot88 Good code / bad code Align each piece of

    code with a S.O.L.I.D principle
  6. 1 3 3 1 3 16 13 2 4 14

    15 6 8 9 12 5 10 11
  7. 3 13 16 1 3 16 13 2 4 14

    15 6 8 9 12 5 10 11
  8. 3 4 2 1 3 16 13 2 4 14

    15 6 8 9 12 5 10 11
  9. 3 15 14 1 3 16 13 2 4 14

    15 6 8 9 12 5 10 11
  10. 3 8 6 1 3 16 13 2 4 14

    15 6 8 9 12 5 10 11
  11. 3 11 9 1 3 16 13 2 4 14

    15 6 8 9 12 5 10 11
  12. 3 10 5 1 3 16 13 2 4 14

    15 6 8 9 12 5 10 11
  13. 12 1 3 16 13 2 4 14 15 6

    8 9 12 5 10 11
  14. @yot88 exercises Practice S.O.L.I.D principles on code examples Clone the

    repository at : https://github.com/ythirion/solid-kata Foreach code example : • identify why it’s breaking the given principle • Write down your refactoring strategy • Refactor it

More Decks by Yoan

Other Decks in How-to & DIY