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

CSE564 Lecture 19

CSE564 Lecture 19

Software Design
Design Smells
(202011)

B546a9b97d993392e4b22b74b99b91fe?s=128

Javier Gonzalez

September 19, 2020
Tweet

Transcript

  1. jgs CSE 564 Software Design Lecture 19: Design Smells Dr.

    Javier Gonzalez-Sanchez javiergs@asu.edu javiergs.engineering.asu.edu | javiergs.com PERALTA 230U Office Hours: By appointment
  2. Javier Gonzalez-Sanchez | CSE564 | Fall 2020 | 2 jgs

    Definition § Design smells are structures in the design that indicate violation of fundamental design principles and negatively impact design quality § The origin of the term design smell can be traced to the term code smell which was featured in the book “Refactoring: Improving the Design of Existing Code” by Martin Fowler.
  3. Javier Gonzalez-Sanchez | CSE564 | Fall 2020 | 3 jgs

    Design smells § Abstraction: Missing or Obsession § Encapsulation: Deficient or Excessive § Modularization: Insufficient, Excessive, or Broken (not make sense) § Hierarchical relationships: unnecessary duplication, broken hierarchies. § Circular dependency: careful with loops
  4. Javier Gonzalez-Sanchez | CSE564 | Fall 2020 | 4 jgs

    General Rules 1. It is about You. Showcase what is yours (your classes) 2. KISS Design. Include one level of hierarchical relationships (do not showcase Java API unless it is needed) 3. DRY Design. If it looks complicated, it smells 4. Semantic. Apply the symbols correctly 5. Be sure diagram and code match
  5. jgs Scenarios

  6. Javier Gonzalez-Sanchez | CSE564 | Fall 2020 | 6 jgs

    Case 01
  7. Javier Gonzalez-Sanchez | CSE564 | Fall 2020 | 7 jgs

    Case 01
  8. Javier Gonzalez-Sanchez | CSE564 | Fall 2020 | 8 jgs

    Case 01 • UIComponent vs JPanel or JButton • Observer and Singleton in a GUI element • Decorator (pattern?) • Stereotype <<Java Class>>
  9. Javier Gonzalez-Sanchez | CSE564 | Fall 2020 | 9 jgs

    Case 02
  10. Javier Gonzalez-Sanchez | CSE564 | Fall 2020 | 10 jgs

    Case 02
  11. Javier Gonzalez-Sanchez | CSE564 | Fall 2020 | 11 jgs

    Case 02 • Looks good but Add methods and attributes • Is NeuralNetwork a singleton, if so, missing the constructor • Careful with strong dependencies
  12. Javier Gonzalez-Sanchez | CSE564 | Fall 2020 | 12 jgs

    Case 03
  13. Javier Gonzalez-Sanchez | CSE564 | Fall 2020 | 13 jgs

    Case 03
  14. Javier Gonzalez-Sanchez | CSE564 | Fall 2020 | 14 jgs

    Case 03 • Smells • Everything is association • Using a JPanel ?! • Search the main and go top-down
  15. Javier Gonzalez-Sanchez | CSE564 | Fall 2020 | 15 jgs

    Case 04
  16. Javier Gonzalez-Sanchez | CSE564 | Fall 2020 | 16 jgs

    Case 04 • Smells • We know the system and it is not so big. • There are so many lines going in or out in several places (a red light)
  17. Javier Gonzalez-Sanchez | CSE564 | Fall 2020 | 17 jgs

    Case 05
  18. Javier Gonzalez-Sanchez | CSE564 | Fall 2020 | 18 jgs

    Case 05 • Smells • It is not about showcasing the Java API. Be careful. • Methods and variables
  19. Javier Gonzalez-Sanchez | CSE564 | Fall 2020 | 19 jgs

    Case 06
  20. Javier Gonzalez-Sanchez | CSE564 | Fall 2020 | 20 jgs

    Case 06
  21. Javier Gonzalez-Sanchez | CSE564 | Fall 2020 | 21 jgs

    Case 06 • Smells • Multiplicity • Factory for Panels • Could main() be added in a child of JFrame ?
  22. Javier Gonzalez-Sanchez | CSE564 | Fall 2020 | 22 jgs

    Case 07
  23. Javier Gonzalez-Sanchez | CSE564 | Fall 2020 | 23 jgs

    Case 07
  24. Javier Gonzalez-Sanchez | CSE564 | Fall 2020 | 24 jgs

    Case 07 • Logger vs Logger Factory • Logger is singleton so, why the aggregation • Variables and Methods
  25. Javier Gonzalez-Sanchez | CSE564 | Fall 2020 | 25 jgs

    Case 08
  26. Javier Gonzalez-Sanchez | CSE564 | Fall 2020 | 26 jgs

    Case 08
  27. Javier Gonzalez-Sanchez | CSE564 | Fall 2020 | 27 jgs

    Case 08 • It is about make it easy to implement • Do not reinvent the wheel • What we get adding Observer to a Listener
  28. jgs Test Yourselves

  29. jgs CSE 564 Computer Systems Fundamentals Javier Gonzalez-Sanchez javiergs@asu.edu Fall

    2020 Disclaimer. These slides can only be used as study material for the class CSE564 at ASU. They cannot be distributed or used for another purpose.