Does Your Architecture Smell?

Does Your Architecture Smell?

Is the quality of your software architecture good? Does it allow you to introduce changes easily? Is it easy enough to understand and explain? To answer these questions and to know their underlying reasons, one needs to know the issues, or more specifically smells in this context, that may occur in a software at architecture granularity. Architecture smells impair quality of the software and make the software hard to maintain and evolve. In this talk, I present seven architecture smells including Feature concentration, God component, Cyclic dependency, Scattered Functionality, and Dense Structure along with their real-world examples. Further, I discuss their impact on various dimensions of software development and propose some pragmatic strategies to avoid, detect, refactor, and manage them.

16a26342d4ff4724dfe59b0dc947dead?s=128

Tushar Sharma

August 10, 2018
Tweet

Transcript

  1. 4.

    • Continuing Growth • All in-use software systems will grow

    • Increasing Complexity • As a software system evolves, the complexity increases unless efforts are made to contain the complexity • Declining Quality • The quality of the software will decline unless it is rigorously maintained Lehman’s laws of software evolution
  2. 7.

    Code Quality: Why to care? Impacted Quality • Changeability •

    Understandability • Extensibility • … Product Quality Code/ Design Quality Quality issues or Smells • Time to market • Reliability: Impacted by poor understandability • … Indicators • Rigidity & Fragility • Immobility & Opacity • Needless complexity • Needless repetition • … Productivity
  3. 8.

    8

  4. 9.

    “Jugaad is a colloquial Hindi word that can mean an

    innovative fix or a simple work-around, used for solutions that bend rules, or a resource that can be used as such, or a person who can solve a complicated issue.” … a work-around or hack जुगाड़ 9 “Jugaad”
  5. 16.
  6. 17.

    What is a smell? …certain structures in the code that

    suggest (sometimes they scream for) the possibility of refactoring. - Kent Beck 20 Definitions of smells: http://www.tusharma.in/smells/smellDefs.html
  7. 18.

    Types of smells • Code smells • Implementation smells •

    Architecture smells • Design smells • Test smells • Performance smells • Configuration smells • Database smells • Models smells • Usability smells • Web smells • …
  8. 26.

    Designite is a software design quality assessment tool for C#.

    Key features • Detects 7 architecture smells • Detects 19 design smells • Detects 11 implementation smells • Computes various object-oriented code metrics • Provides smell trend analysis of Git repositories • Many visualization aids including smell treemap, and smell sunburst • Detects code duplication • Allows customization of analysis • Smart tracking of detected smells http://www.designite-tools.com Academic license is free!
  9. 27.

    God Component when a component is excessively large either in

    the terms of LOC or number of classes.
  10. 29.

    Stable Dependencies Principle (SDP) dependencies between packages should be in

    the direction of the stability of the packages. = ( + ) Ca - afferent coupling (or incoming dependencies) Ce - efferent coupling (or outgoing dependencies)
  11. 31.

    Feature Concentration A1, A2 D1 C1, C2, C3, C4 when

    a component is realizing more than one architectural concern/feature. In other words, the component is not cohesive. B1
  12. 34.

    Dense Structure Average degree = 2 ∗|| || when components

    have excessive and dense dependencies without any particular structure.
  13. 35.

    Architecture smells in open-source projects Arch smells #Instances Smell density

    Cyclic dependency 34,556 0.415 Feature concentration 17,420 0.209 Scattered functionality 11,623 0.139 Unstable dependency 10,195 0.122 God component 4,774 0.057 Ambiguous interface 852 0.010 Dense structure 302 0.003 Repositories: 3,209 containing > 83 MLOC (C#)
  14. 38.

    Awareness Does the development team well aware about: • Smells

    and resultant technical debt • Their impact on their project • Code quality, clean code practices Train • Training • Books • Workshops/conferences • …
  15. 39.

    Processes Employ pragmatic processes to bring discipline Review process •

    Code reviews Architecture governance • Adherence to collection of guidelines and controls People care about things that you measure and reward!
  16. 41.

    Detecting and refactoring smells: strategies 1. Identify and track 2.

    Prioritize 3. Refactoring installments 4. Follow the ‘Boy’s scout rule’ 5. Motivate 6. Periodically, aim for large-scale refactoring 7. Refactor, except
  17. 43.
  18. 45.

    An architecture smell A R C H I T E

    C T U R E S M E L L S J U G A A D
  19. 46.

    Tool to detect smells A R C H I T

    E C T U R E S M E L L S O D C O M P O N E N T J U G A A D
  20. 47.

    A way to improve A R C H I T

    E C T U R E S M E L L S O D C O M P O N E N T J U G A A D D E S I G N I T E
  21. 48.

    A W A R E E S S G O

    D C O M P O N E N T D S I G N I T E J U G A A D A R C H I T E C T U R E S M E L L S