SlideShare a Scribd company logo
Girish Suryanarayana, Ganesh Samarthyam, Tushar Sharma
2
Outline
Introduction – Design Quality,
Technical Debt, and Design Smells
Design Smells Catalog – Examples
and corresponding Refactoring
The Smell Ecosystem and Repaying
Technical Debt in Practice
3
Outline
Introduction – Design Quality,
Technical Debt, and Design Smells
Design Smells Catalog – Examples
and corresponding Refactoring
The Smell Ecosystem and Repaying
Technical Debt in Practice
Capers Jones on design errors in industrial software
* http://sqgne.org/presentations/2012-13/Jones-Sep-2012.pdf
0
20
40
60
80
100
120
IBM Corportation
(MVS)
SPR Corporation
(Client Studies)
TRW Corporation MITRE Corporation Nippon Electric
Corp
PercentageContribution
Industry Data on Defect Origins
Adminstrative Errors
Documentation Errors
Bad Fixes
Coding Errors
Design Errors
Requirements Errors
Up to 64% of software defects can
be traced back to errors in
software design in enterprise
software!
Why care about design quality?
Poor software quality
costs more than $150
billion per year in U.S. and
greater than $500 billion
per year worldwide
The debt that accrues when
you knowingly or
unknowingly make wrong or
non-optimal design decisions
Software
Quality
Technical
Debt
Design
Quality
Design Quality means
changeability, extensibility,
understandability,
reusability, ...
6
Why care about technical debt?
Global 'IT Debt‘ is $500 billion for the
year 2010,with potential to grow to $1
trillion by 2015
7
What constitutes technical debt?
…
Code debt
Static analysis
tool violations
Inconsistent
coding style
Design debt
Design smells
Violations of
design rules
Test debt
Lack of tests
Inadequate test
coverage
Documentation
debt
No
documentation
for important
concerns
Outdated
documentation
“Design smells” aka…
“Smells are certain structures in the code that suggest (sometimes they
scream for) the possibility of refactoring.”
What is a smell?
9
Why care about smells?
Impacted Quality
§ Reusability
§ Changeability
§ Understandability
§ Extensibility
§ …
Product
Quality
Design
Quality
Design
Smells
Impacted Quality
§ Maintainability: Affected
by changeability &
extensibility
§ Reliability: Impacted by
poor understandability
§ …
Indicators
§ Rigidity & Fragility
§ Immobility & Opacity
§ Needless complexity
§ Needless repetition
§ …
10
What causes design smells?
11
Why we focus on smells?
A good designer is
one who knows the
design solutions
A GREAT designer is
one who understands
the impact of design
smells and knows
how to address them
12
Design Smells as violations of fundamental principles
What do smells indicate?
Violations of fundamental design principles
We use Booch’s fundamental principles for classification and naming of
smells
This helps identify cause of the smell and potential refactoring as well
13
Principles used to classify design smells
14
Quality attributes impacted by smells
15
A principle-based approach to design smells classification
Related Publications
S G Ganesh, Tushar Sharma, Girish Suryanarayana. Towards a Principle-based
Classification of Structural Design Smells. In Journal of Object Technology, vol. 12,
no. 2, 2013, pages 1:1–29.doi:10.5381/jot.2013.12.2.a1
URL: http://www.jot.fm/issues/issue_2013_06/article1.pdf (open access)
16
Summary till now
Design Quality
Technical Debt
Design Smells
Why care about smells
17
Outline
Introduction – Design Quality,
Technical Debt, and Design Smells
Design Smells Catalog – Examples
and corresponding Refactoring
The Smell Ecosystem and Repaying
Technical Debt in Practice
18
19
A note on examples in this presentation
We cover only a few examples of each smell category in this presentation
Lack of time
Most examples are from OpenJDK 7.0 (open source)
All illustrations are mostly as UML diagrams so no need to know Java
(though you’ll appreciate more if you know Java)
Almost all examples are UML-like diagrams – so agnostic of OO language
Some code examples are in Java, but they are very few
20
21
The principle of abstraction
22
Enabling techniques for abstraction
23
24
Incomplete abstraction
This smell arises when a type does not support a responsibility
completely
Specifically, the public interface of the type is incomplete in that it
does not support all behavior needed by objects of its type
25
Incomplete abstraction – Example
In this case, the MutableTreeNode
supports only setUserObject but no
corresponding getUserObject (which
is provided in its derived class!)
Hence, MutableTreeNode has
Incomplete Abstraction smell
How to fix it? Provide all the
necessary and relevant methods
required for satisfying a
responsibility completely in the class
itself
In case of public APIs (as in this
case), it is often “too late” to fix
it!
26
Another example
27
28
How to refactor & in future avoid this smell?
For each abstraction (especially in public interface) look out for symmetrical
methods or methods that go together
For example, methods for comparing equality of objects and getting
hash code (in Java/C#)
Look out for missing matching methods in symmetrical methods (see
table)
min/max open/close create/destroy get/set
read/write print/scan first/last begin/end
start/stop lock/unlock show/hide up/down
source/target insert/delete first/last push/pull
enable/disable acquire/release left/right on/off
29
30
Duplicate abstraction
This smell arises when two or more abstractions have identical
names or identical implementation or both.
31
32
Kinds of clones
• exactly identical except for variations in whitespace, layout, and
comments
Type 1
• syntactically identical except for variation in symbol names,
whitespace, layout, and comments
Type 2
• identical except some statements changed, added, or removed
Type 3
• when the fragments are semantically identical but implemented
by syntactic variants
Type 4
33
public class FormattableFlags {
// Explicit instantiation of this class is prohibited.
private FormattableFlags() {}
/** Left-justifies the output. */
public static final int LEFT_JUSTIFY = 1<<0; // '-'
/** Converts the output to upper case */
public static final int UPPERCASE = 1<<1; // 'S'
/**Requires the output to use an alternate form. */
public static final int ALTERNATE = 1<<2; // '#'
}
34
public class Dollar {
public static final String symbol = “$”;
}
35
Unnecessary abstraction
The smell occurs when an abstraction gets introduced in a software
design which is actually not needed and thus could have been avoided.
36
37
The principle of encapsulation
38
Enabling techniques for encapsulation
39
40
41
Leaky encapsulation
This smell arises when an abstraction “exposes” or “leaks”
implementation details through its public interface.
42
Refactoring leaky encapsulation smell
43
44
45
Missing encapsulation
This smell occurs when the encapsulation of implementation
variations in a type or hierarchy is missing.
46
Refactoring missing encapsulation smell
47
Refactoring missing encapsulation smell
48
49
The principle of modularization
50
Enabling techniques for modularization
51
52
53
Insufficient modularization
This smell arises when an existing abstraction could be further
decomposed thereby reducing its interface size, implementation
complexity or both. Two variants:
a) When an abstraction has a large number of members in its interface, its
implementation, or both
b) When an abstraction has one or more methods with excessive complexity
54
Insufficient modularization – Example
The abstract class java.awt.Component is
an example of insufficient modularization
It is a massive class with 332 methods
(of which 259 are public!)
11 nested/inner classes
107 fields (including constants)
source file spans 10,102 lines of
code!
The Component serves as a base class
and the hierarchy is deep
Derived classes inherit the members
=> life is quite difficult!
55
56
57
58
Cyclically-dependent modularization
This smell arises when two or more class-level abstractions depend
on each other directly or indirectly (creating a tight coupling among
the abstractions).
(This smell is commonly known as “cyclic dependencies”)
59
Refactoring cyclically-dependent modularization
60
Refactoring cyclically-dependent modularization
61
Refactoring cyclically-dependent modularization
62
Refactoring cyclically-dependent modularization
63
Refactoring cyclically-dependent modularization
64
Refactoring cyclically-dependent modularization
65
66
The principle of hierarchy
67
Enabling techniques for hierarchy
68
69
70
Unfactored hierarchy
This smell arises when the types in a hierarchy share unnecessary
duplication in the hierarchy. Two forms of this smell:
• Duplication in sibling types
• Duplication in super and subtypes
71
A refactoring for missing intermediate types
72
Refactoring for unfactored hierarchy
73
Refactoring for unfactored hierarchy
74
75
76
77
Broken hierarchy
This smell arises when the base abstraction and its derived
abstraction(s) conceptually do not share “IS-A” relationship
(resulting in broken substitutability).
This design smell arises when inheritance is used wrongly instead of
using composition.
78
LSP
It should be possible to replace
objects of supertype with
objects of subtypes without
altering the desired behavior of
the program
79
Refactoring broken hierarchy
80
Refactoring broken hierarchy
81
82
83
Unnecessary hierarchy
This smell arises when an inheritance hierarchy has one or more unnecessary
abstractions. Includes the following cases:
• all the subtypes are unnecessary (i.e., inappropriate use of inheritance)
• supertype has only one subtype (i.e., speculative generalization)
• intermediate types are unnecessary
84
Refactoring unnecessary hierarchy
85
Refactoring unnecessary hierarchy
86
Refactoring unnecessary hierarchy
87
Summary till now
Abstraction Smells
Incomplete Abstraction
Duplicate Abstraction
Unnecessary Abstraction
Encapsulation Smells
Leaky Encapsulation
Missing Encapsulation
Modularization Smells
Insufficient Modularization
Cyclically-dependent Modularization
Hierarchy Smells
Unfactored Hierarchy
Broken Hierarchy
Unnecessary Hierarchy
88
Outline
Introduction – Design Quality,
Technical Debt, and Design Smells
Design Smells Catalog – Examples
and corresponding Refactoring
The Smell Ecosystem and Repaying
Technical Debt in Practice
89
Smell Ecosystem
DD
DD
DD
DD
DD
Smell
Smell
Smell
DD
DD: Design Decision
Design
90
Role of context in smells and refactoring
Could it be Duplicate
Abstraction, Unfactored
Hierarchy, or Unnecessary
Abstraction smell?
91
Interplay of Smells: Co-occurring smells
92
Interplay of Smells: Amplification
Insufficient Modularization
smell due to Component
class amplify the impact of
deep hierarchy negatively.
93
Interplay of Smells: Deeper problems
94
How to improve design quality in practice?
95
Refactoring process model
96
What were your key takeaways?
97
Our upcoming book on this topic!
98
99
References
100
Ganesh Samarthyam
sgganesh@gmail.com
Twitter@GSamarthyam
Girish Suryanarayana
girish.suryanarayana@gmail.com
Twitter@girish_sur
Tushar Sharma
tusharsharma@ieee.org
Twitter@Sharma__Tushar

More Related Content

PDF
Refactoring for Software Design Smells - 1 day Workshop
PPTX
Refactoring for design smells
PDF
Code Smells and Its type (With Example)
PPTX
Code smells and remedies
PPTX
Code smell overview
PDF
Bad Code Smells
PDF
Refactoring: Improve the design of existing code
PDF
Clean code: meaningful Name
Refactoring for Software Design Smells - 1 day Workshop
Refactoring for design smells
Code Smells and Its type (With Example)
Code smells and remedies
Code smell overview
Bad Code Smells
Refactoring: Improve the design of existing code
Clean code: meaningful Name

What's hot (20)

PPTX
Core java
PDF
5 collection framework
PDF
Osquery
PDF
GoldenGateテクニカルセミナー2「Oracle GoldenGate 新機能情報」(2016/5/11)
PDF
Introduction to Design Pattern
PDF
Design patterns
PDF
Diffing Shotgun Surgery and Divergent Change smells in the two editions of Re...
PDF
Oracle GoldenGate 19c を使用した 簡単データベース移行ガイド_v1.0
PPTX
Introduction to Java
PPTX
Design pattern (Abstract Factory & Singleton)
PDF
Memory Leak In java
PDF
SOLID Principle & Design Pattern.pdf
PPT
Introduction to design patterns
PDF
Java Performance and Profiling
PPTX
Data Stream Management
PPTX
Instalasi.LINUX.Ubuntu.pptx
PDF
Bridge pattern for Dummies
PPTX
Error Recovery strategies and yacc | Compiler Design
PDF
Hibernate Presentation
KEY
Solid principles
Core java
5 collection framework
Osquery
GoldenGateテクニカルセミナー2「Oracle GoldenGate 新機能情報」(2016/5/11)
Introduction to Design Pattern
Design patterns
Diffing Shotgun Surgery and Divergent Change smells in the two editions of Re...
Oracle GoldenGate 19c を使用した 簡単データベース移行ガイド_v1.0
Introduction to Java
Design pattern (Abstract Factory & Singleton)
Memory Leak In java
SOLID Principle & Design Pattern.pdf
Introduction to design patterns
Java Performance and Profiling
Data Stream Management
Instalasi.LINUX.Ubuntu.pptx
Bridge pattern for Dummies
Error Recovery strategies and yacc | Compiler Design
Hibernate Presentation
Solid principles
Ad

Viewers also liked (20)

PDF
Refactoring for Software Design Smells: Managing Technical Debt
PDF
Refactoring - An Introduction
PPT
Refactoring Tips by Martin Fowler
PPT
The Smells Of Bad Design
PDF
Achieving Design Agility by Refactoring Design Smells
PDF
Designite – Software Design Quality Assessment Tool
PPTX
Refactoring Legacy Web Forms for Test Automation
PPT
Principles in Refactoring
PDF
Service design for networked business models - presentation at Service Design...
PPTX
Clean Code I - Design Patterns and Best Practices at SoCal Code Camp San Dieg...
PPTX
Quality By Design
PDF
PHAME: Principles of Hierarchy Abstraction Modularization and Encapsulation
PPT
Design Smells
PPTX
Network design - Topology
PDF
Refactoring 101
PPTX
yeni ürün ve yeni pazarlara giriş stratejileri
PDF
MARKA OLUSTURMAK
PDF
Refactoring to Java 8 (Devoxx BE)
PPTX
Network design
PDF
Tasarim ve üretim
Refactoring for Software Design Smells: Managing Technical Debt
Refactoring - An Introduction
Refactoring Tips by Martin Fowler
The Smells Of Bad Design
Achieving Design Agility by Refactoring Design Smells
Designite – Software Design Quality Assessment Tool
Refactoring Legacy Web Forms for Test Automation
Principles in Refactoring
Service design for networked business models - presentation at Service Design...
Clean Code I - Design Patterns and Best Practices at SoCal Code Camp San Dieg...
Quality By Design
PHAME: Principles of Hierarchy Abstraction Modularization and Encapsulation
Design Smells
Network design - Topology
Refactoring 101
yeni ürün ve yeni pazarlara giriş stratejileri
MARKA OLUSTURMAK
Refactoring to Java 8 (Devoxx BE)
Network design
Tasarim ve üretim
Ad

Similar to Refactoring for Design Smells - ICSE 2014 Tutorial (20)

PDF
Refactoring for software design smells - icse 2014 tutorial
PDF
Refactoring for design smells - concise poster
PDF
Design Smell Descriptions - Summary Sheet
PDF
Does your design smell - Tushar Sharma
PDF
Design smells poster
PDF
Refactoring guided by design principles driven by technical debt
PDF
FUNCTIONAL OVER-RELATED CLASSES BAD SMELL DETECTION AND REFACTORING SUGGESTIONS
DOCX
A Study on Code Smell Detection with Refactoring Tools in Object Oriented Lan...
PDF
Principle based classification of design smells
PDF
Functional over related classes bad smell detection and refactoring suggestions
PDF
Code smells
PDF
Refactoring for Software Architecture Smells - International Workshop on Refa...
PDF
A Checklist for Design Reviews
PDF
Refactoring for Software Design Smells Book - A Visual Overview
PDF
Refactoring for architecture smells an introduction
PDF
Refactoring for Software Design Smells - Tech Talk
PDF
Refactoring for Software Design Smells - Tech Talk
PDF
Synopsis ( Code Smells)
PDF
Software process versus design quality a tug of war - ieee software july 2015
DOCX
Synopsis minor project
Refactoring for software design smells - icse 2014 tutorial
Refactoring for design smells - concise poster
Design Smell Descriptions - Summary Sheet
Does your design smell - Tushar Sharma
Design smells poster
Refactoring guided by design principles driven by technical debt
FUNCTIONAL OVER-RELATED CLASSES BAD SMELL DETECTION AND REFACTORING SUGGESTIONS
A Study on Code Smell Detection with Refactoring Tools in Object Oriented Lan...
Principle based classification of design smells
Functional over related classes bad smell detection and refactoring suggestions
Code smells
Refactoring for Software Architecture Smells - International Workshop on Refa...
A Checklist for Design Reviews
Refactoring for Software Design Smells Book - A Visual Overview
Refactoring for architecture smells an introduction
Refactoring for Software Design Smells - Tech Talk
Refactoring for Software Design Smells - Tech Talk
Synopsis ( Code Smells)
Software process versus design quality a tug of war - ieee software july 2015
Synopsis minor project

More from Tushar Sharma (17)

PDF
House of Cards: Code Smells in Open-source C# Repositories
PDF
The tail of two source-code analysis tools - Learning and experiences
PDF
Designite: A Customizable Tool for Smell Mining in C# Repositories
PDF
Writing Maintainable Code
PDF
FOSDEM - Does your configuration code smell?
PDF
Does your configuration code smell?
PDF
Does Your Configuration Code Smell?
PDF
Technical debt - The elephant in the room
PDF
Understanding software metrics
PDF
Pragmatic Technical Debt Management
PDF
Tools for Identifying and Addressing Technical Debt
PDF
Infographic - Pragmatic Technical Debt Management
PDF
Applying Design Principles in Practice
PDF
Why care about technical debt?
PDF
Does your design smell?
PDF
Tools for refactoring
PDF
Towards a Principle-based Classification of Structural Design Smells
House of Cards: Code Smells in Open-source C# Repositories
The tail of two source-code analysis tools - Learning and experiences
Designite: A Customizable Tool for Smell Mining in C# Repositories
Writing Maintainable Code
FOSDEM - Does your configuration code smell?
Does your configuration code smell?
Does Your Configuration Code Smell?
Technical debt - The elephant in the room
Understanding software metrics
Pragmatic Technical Debt Management
Tools for Identifying and Addressing Technical Debt
Infographic - Pragmatic Technical Debt Management
Applying Design Principles in Practice
Why care about technical debt?
Does your design smell?
Tools for refactoring
Towards a Principle-based Classification of Structural Design Smells

Recently uploaded (20)

PPTX
CHAPTER 2 - PM Management and IT Context
PDF
top salesforce developer skills in 2025.pdf
PDF
Adobe Illustrator 28.6 Crack My Vision of Vector Design
PDF
Why TechBuilder is the Future of Pickup and Delivery App Development (1).pdf
PDF
2025 Textile ERP Trends: SAP, Odoo & Oracle
PDF
Understanding Forklifts - TECH EHS Solution
PDF
Wondershare Filmora 15 Crack With Activation Key [2025
PPTX
Agentic AI Use Case- Contract Lifecycle Management (CLM).pptx
PPTX
VVF-Customer-Presentation2025-Ver1.9.pptx
PDF
Claude Code: Everyone is a 10x Developer - A Comprehensive AI-Powered CLI Tool
PPTX
L1 - Introduction to python Backend.pptx
PDF
AI in Product Development-omnex systems
PPTX
Operating system designcfffgfgggggggvggggggggg
PPTX
Odoo POS Development Services by CandidRoot Solutions
PDF
Navsoft: AI-Powered Business Solutions & Custom Software Development
PDF
How to Choose the Right IT Partner for Your Business in Malaysia
PDF
Design an Analysis of Algorithms II-SECS-1021-03
PDF
wealthsignaloriginal-com-DS-text-... (1).pdf
PPTX
Essential Infomation Tech presentation.pptx
PDF
medical staffing services at VALiNTRY
CHAPTER 2 - PM Management and IT Context
top salesforce developer skills in 2025.pdf
Adobe Illustrator 28.6 Crack My Vision of Vector Design
Why TechBuilder is the Future of Pickup and Delivery App Development (1).pdf
2025 Textile ERP Trends: SAP, Odoo & Oracle
Understanding Forklifts - TECH EHS Solution
Wondershare Filmora 15 Crack With Activation Key [2025
Agentic AI Use Case- Contract Lifecycle Management (CLM).pptx
VVF-Customer-Presentation2025-Ver1.9.pptx
Claude Code: Everyone is a 10x Developer - A Comprehensive AI-Powered CLI Tool
L1 - Introduction to python Backend.pptx
AI in Product Development-omnex systems
Operating system designcfffgfgggggggvggggggggg
Odoo POS Development Services by CandidRoot Solutions
Navsoft: AI-Powered Business Solutions & Custom Software Development
How to Choose the Right IT Partner for Your Business in Malaysia
Design an Analysis of Algorithms II-SECS-1021-03
wealthsignaloriginal-com-DS-text-... (1).pdf
Essential Infomation Tech presentation.pptx
medical staffing services at VALiNTRY

Refactoring for Design Smells - ICSE 2014 Tutorial