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

CSE564 Lecture 24

CSE564 Lecture 24

Software Design
Design Smells
(202011)

B546a9b97d993392e4b22b74b99b91fe?s=128

Javier Gonzalez
PRO

September 24, 2020
Tweet

Transcript

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

    Javier Gonzalez-Sanchez javiergs@asu.edu javiergs.engineering.asu.edu | javiergs.com PERALTA 230U Office Hours: By appointment
  2. jgs 00010000 Design Smells structures in the design that indicate

    violation of fundamental design principles and negatively impact design quality
  3. jgs 00010000 Note 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.
  4. jgs 00010000 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
  5. jgs 00010000 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
  6. jgs Scenarios

  7. jgs Javier Gonzalez-Sanchez | SER332 | Spring 2018 | 8

  8. jgs Javier Gonzalez-Sanchez | SER332 | Spring 2018 | 9

  9. jgs Javier Gonzalez-Sanchez | SER332 | Spring 2018 | 10

  10. jgs 00010000

  11. jgs 00010000

  12. jgs 00010000

  13. jgs Javier Gonzalez-Sanchez | SER332 | Spring 2018 | 14

  14. jgs Test Yourselves

  15. jgs 00010000

  16. jgs 00010000

  17. jgs Javier Gonzalez-Sanchez | SER332 | Spring 2018 | 18

  18. jgs Javier Gonzalez-Sanchez | SER332 | Spring 2018 | 19

  19. jgs Javier Gonzalez-Sanchez | SER332 | Spring 2018 | 20

  20. jgs Javier Gonzalez-Sanchez | SER332 | Spring 2018 | 21

  21. jgs Javier Gonzalez-Sanchez | SER332 | Spring 2018 | 22

  22. jgs Summary To do List

  23. jgs 00010000 Additional Feedback :: Common Errors 1. Define association

    relationships between classes but have global variables in the code. 2. Using association and aggregation interchangeably. They are not the same 3. Classes are missing either in the class diagram or in the code –code and design are inconsistent. 4. Designs are too complex to understand with lines between classes overlapping. I have to say quite the opposite of Occam's Razor. the simplest explanation is usually the correct one
  24. jgs 00010000 Additional Feedback 5. Classes are empty or unconnected

    with the rest of the classes. 6. Using realization and inheritance interchangeably and these relationships don't reflect in the code. 7. Minor Issue: some of the classes that come with java like JPanel, JFrame, JButton are missing in the class diagrams even though they have used them in the code. 8. Request: Help us to color system classes with diverse colors (API vs Your own). Hard to interpret and check for them in the code.
  25. jgs 00010000 Case 01 • Observer and Singleton in a

    GUI element (View)? • Decorator (incomplete?)
  26. jgs 00010000 Case 02 • Looks good but methods and

    attributes seems to be missing • Careful with strong dependencies
  27. jgs 00010000 Case 03 • Everything is association • Some

    class Using a JPanel ?! • Search the main and go top-down
  28. jgs 00010000 Case 04 • 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)
  29. jgs 00010000 Case 05 • It is not about showcasing

    the Java API. Be careful. • Methods and variables
  30. jgs 00010000 Case 06 • Multiplicity • Factory for Panels

    ! • Could main() be totally disconnected from JFrame ?
  31. jgs 00010000 Case 08 • It is about make it

    easy to implement • Do not reinvent the wheel • What we get adding Observer to a Listener !
  32. 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.