Slide 1

Slide 1 text

Does Your Architecture Smell? Tushar Sharma

Slide 2

Slide 2 text

Architecture smells Why to care? Types and granularities Examples How to detect Smells How to avoid

Slide 3

Slide 3 text

http://www.tusharma.in

Slide 4

Slide 4 text

• 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

Slide 5

Slide 5 text

Evolution of JUnit 3.7 4.0 4.5 4.11

Slide 6

Slide 6 text

Which one is easy to work with?

Slide 7

Slide 7 text

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

Slide 8

Slide 8 text

8

Slide 9

Slide 9 text

“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”

Slide 10

Slide 10 text

10 “Jugaad”

Slide 11

Slide 11 text

“Jugaad” 11

Slide 12

Slide 12 text

“Jugaad” 12

Slide 13

Slide 13 text

“Jugaad” 13

Slide 14

Slide 14 text

“Jugaad” 14

Slide 15

Slide 15 text

Smells are Jugaads in software 15

Slide 16

Slide 16 text

No content

Slide 17

Slide 17 text

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

Slide 18

Slide 18 text

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 • …

Slide 19

Slide 19 text

Smells: Types http://www.tusharma.in/smells/

Slide 20

Slide 20 text

Granularity of code smells - Implementation - Design - Architecture

Slide 21

Slide 21 text

Implementation smells

Slide 22

Slide 22 text

Design Smells

Slide 23

Slide 23 text

Architecture Smells

Slide 24

Slide 24 text

Architecture smells: examples

Slide 25

Slide 25 text

Demo http://www.designite-tools.com

Slide 26

Slide 26 text

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!

Slide 27

Slide 27 text

God Component when a component is excessively large either in the terms of LOC or number of classes.

Slide 28

Slide 28 text

Cyclic Dependency When two or more architecture components depend on each other directly or indirectly

Slide 29

Slide 29 text

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)

Slide 30

Slide 30 text

Unstable Dependencies when a component depends on other components that are less stable than itself. IA < IB A B

Slide 31

Slide 31 text

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

Slide 32

Slide 32 text

Ambiguous interface when a component offers only a single, general entry-point into the component.

Slide 33

Slide 33 text

Scattered functionality when multiple components are responsible for realizing the same high-level concern

Slide 34

Slide 34 text

Dense Structure Average degree = 2 ∗|| || when components have excessive and dense dependencies without any particular structure.

Slide 35

Slide 35 text

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#)

Slide 36

Slide 36 text

Managing smells in practice

Slide 37

Slide 37 text

Managing smells Prevent Detect and remove Awareness Processes Strategies

Slide 38

Slide 38 text

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 • …

Slide 39

Slide 39 text

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!

Slide 40

Slide 40 text

Detecting and refactoring smells: Key strategies

Slide 41

Slide 41 text

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

Slide 42

Slide 42 text

Let us conclude

Slide 43

Slide 43 text

A Hack

Slide 44

Slide 44 text

J U G A A D Quality issues at architecture granularity

Slide 45

Slide 45 text

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

Slide 46

Slide 46 text

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

Slide 47

Slide 47 text

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

Slide 48

Slide 48 text

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

Slide 49

Slide 49 text

Tushar Sharma tusharsharma@ieee.org http://www.tusharma.in Thank you!! Courtesy: spikedmath.com