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

[Global summit for java Devs 2021] Clean Archit...

[Global summit for java Devs 2021] Clean Architecture? Clean Code? Refactoring? Tests? What does this change in my code?

In this talk we will cover concepts and applications of clean architecture, clean code, when and how to refactor our code and why it is important to write tests, with examples in Java and Spring Boot. I intend to pass on some good development practices that I have been learning and are widely used in the market.

More Decks by Kamila de fatima santos oliveira

Other Decks in Programming

Transcript

  1. Backend developer at Ame Digital, Microsoft MVP, Book co- author,

    community co-organizer, content creator at kamila_code Kamila Santos @kamila_code
  2. CLEAN CODE Clean code is simple and easy to follow

    , with isolated scope , easy to be tested , and well (self ) documented @kamila_code
  3. CLEAN CODE “Any fool can write code that a computer

    can understand . Good programmers write code that humans can understand . ” Martin Fowler @kamila_code
  4. CLEAN CODE Scout rule : Always leave the code better

    than you found it . ... @kamila_code
  5. CLEAN CODE Don 't define names with what you find

    most beautiful / cute @kamila_code
  6. BLOATERS Code , methods and classes that have grown too

    much , accumulate over time as the program evolves @kamila_code
  7. BLOATERS - LARGE CLASS A class that contains many lines

    of code , methods and fields . @kamila_code
  8. BLOATERS - PRIMITIVE OBSESSION Use string constants as field names

    and constants for code information :USER _ADMIN _ROLE = 1 @kamila_code
  9. BLOATERS - DATA CLUMPS Parts of code that contain identical

    groups of variables (such as parameters of externals configs) @kamila_code
  10. OO ABUSERS - ALTERNATIVE CLASSES WITH DIFFERENT INTERFACES Two or

    more class perform identical functions but have different methods names @kamila_code
  11. CHANGE PREVENTERS If you need to change something in one

    place of your code , you have to make many changes in other places too @kamila_code
  12. DISPENSABLES something unnecessary and meaningless, the absence of which would

    make the code more efficient, easier to understand and cleaner @kamila_code
  13. COUPLERS Contribute to excessive coupling between classes or show what

    happens if coupling is replaced by excessive delegation @kamila_code
  14. REFACTORING Refactoring is the process of changing a software system

    in a way that it does not change its external behavior, but has an improved internal structure. @kamila_code
  15. TECHNICAL DEBT Consists of additional rework costs caused by choosing

    the easiest / fastest solution instead of using the best solution that would take longer @kamila_code
  16. CAUSES OF TECHNICAL DEBT Lack of well -defined development standards

    or lack of knowledge on the part of the team @kamila_code
  17. WHEN TO REFACTOR ? when you go through the code

    and see the possibility of it being improved (and you can invest time in it ) @kamila_code
  18. HOW TO REFACTOR A CODE ? The new code needs

    to be cleaner than the previous one @kamila_code
  19. HOW TO REFACTOR A CODE ? the new code should

    be better performing than the previous one @kamila_code
  20. HOW TO REFACTOR A CODE ? New functionalities shouldn ’t

    be created during refactoring @kamila_code
  21. SIMPLIFYING METHOD CALLS This technique make methods calls simplier and

    easier to use , modifying the interfaces for interaction @kamila_code
  22. COMPOSING METHODS In this category we remove code duplication ,

    simplifies methods and prepares application for other refactorings . @kamila_code
  23. MOVING FEATURES BETWEEN OBJECTS Teach how safely move features between

    classes , hide implementation details and create new classes . @kamila_code
  24. EXTRACT METHOD Problem: a method with more than one responsibility,

    which can be extracted for a new method @kamila_code
  25. TEST SUITE collection of test cases or specs designed to

    test a program for a specific behavior @kamila_code
  26. TEST SUITE Test suites are usually divided according to the

    functionality of the system or the type of test performed @kamila_code
  27. TEST CASE Test Case shows the paths taken by a

    module , Use Case or functionality within the project . @kamila_code
  28. JUNIT PLATFORM exposes the TestEngine interface , which defines the

    execution contract for any testing tool on the JUnit platform @kamila_code
  29. JUNIT JUPITER Contains new features for building tests using JUnit

    , and provides a TestEngine implementation for running tests written with JUnit Jupiter . @kamila_code
  30. ASSERTS it is a useful method for determining the Pass

    or Fail status of a test case . Declaration methods are provided by the org .junit .Assert class that extends the java .lang .Object class @kamila_code
  31. ANNOTATIONS is a special form of syntactic metadata that can

    be added to the Java source code for better readability and code structure @kamila_code
  32. CLEAN ARCHITECTURE it tries to provide a way to organize

    the code so that it encapsulates the business logic and remains separate from the rest of the application and cannot be accessed directly @kamila _code
  33. CONCLUSION about the clean architecture, it helps to better separate

    the responsibilities of the application, the negative point is that there is a much larger number of files and requires a certain amount of learning time to understand what each module / package is for @kamila _code
  34. CONCLUSION this can also occur with other architectures and design

    patterns, it is worth evaluating what will improve in the application and if the team understands how to apply @kamila _code
  35. CONCLUSION implanting the test culture can be complicated, mainly because

    it increases the development time including the tests, but it is one more way to always guarantee the functioning of the business rules of the system @kamila _code
  36. CONCLUSION in addition to the techniques mentioned here of refactoring

    there are several other techniques that help a lot, for those who have the culture of TDD refactoring is already part of the development cycle, so it is easier to remember this stage in development @kamila _code
  37. CONCLUSION having unit tests also helps new people who join

    the project to understand the business rules and find bugs more easily @kamila _code
  38. THAT'S ALL FOLKS https://linktr.ee/kamila.dev thank you very much and add

    me on social networks on the link above to keep in touch and answer questions about the presentation @kamila_code