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

Learn_4_Key_Principles_to_Craft_High-Quality_Co...

 Learn_4_Key_Principles_to_Craft_High-Quality_Code.pdf

Thiago

June 17, 2023
Tweet

More Decks by Thiago

Other Decks in Technology

Transcript

  1. Table of contents The Dependency Inversion Principle The Single Responsibility

    Principle Don’t Repeat Yourself Keep It Simple, Stupid 01 02 04 03 SRP DRY DIP KISS
  2. — Robert C. Martin “Gather together those things that change

    for the same reason, and separate those things that change for different reasons. ”
  3. The Single Responsibility Principle How can you apply SRP? •

    Keep your classes and methods small. • Be careful with many dependencies, look at your imports.
  4. The Single Responsibility Principle How can you identify if you

    are not applying the SRP? • If you need to change many files to include or change a behavior. • If you need to change the same file for more than one reason.
  5. — Robert C. Martin - Clean Code “This is one

    of the most important rules in this book, and you should take it very seriously. ”
  6. Don’t Repeat Yourself How can you apply DRY? • Avoid

    duplication. • Any time you see duplication in the code, it could probably become a subroutine or maybe another class outright.
  7. Don’t Repeat Yourself How can you identify if you are

    not applying the DRY? • If you are doing Ctrl+C/Ctrl+V and nothing changes. • If you need to resolve the same problem twice in different places.
  8. — Robert C. Martin “Depend in the direction of abstraction.

    High level modules should not depend upon low level details. ”
  9. The Dependency Inversion Principle How can you apply DIP? •

    Use abstraction to separate the layers. • Don’t depend on the implementation, depend on the abstractions.
  10. The Dependency Inversion Principle How can you identify if you

    are not applying the DIP? • If you need to change your core application, or your domain because some API you consume changes, you are probably violating the DRY. • Can you change the API you consume to another vendor? If you can’t, maybe you are violation the DRY.
  11. — Antoine de Saint-Exupery “Perfection is achieved not when there

    is nothing more to add, but when there is nothing left to take away. ”
  12. Keep It Simple, Stupid How can you apply KISS? •

    Avoid complex architectures and design solutions to solve simple problems. • Simplicity should be a key design goal, and complicated complexity should be avoided.
  13. Keep It Simple, Stupid How can you identify if you

    are not applying the KISS? • How easy is your solution to be understood and extended? • Are you doing premature optimization?
  14. CREDITS: This presentation template was created by Slidesgo, and includes

    icons by Flaticon, and infographics & images by Freepik Thanks! Do you have any questions? @ThiagoBfim