Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.
House of Cards:
Code Smells in Open-source C# Repositories
Tushar Sharma, Marios Fragkoulis, and Diomidis Spinellis
Funded...
Code Smells
…certain structures in the code
that suggest (sometimes they
scream for) the possibility of
refactoring.
- Ken...
http://www.tusharma.in/smells/
A Taxonomy of Software Smells
Identified gap
• Existing mining studies on smells lack
• scale (Number of subject systems analyzed), and
• breadth (Numbe...
Overview of the study
Research
questions
1988 open-source
repositories
Designite
<!>
19 Design smells
11 Implementation
sm...
Detected design smells
Abstraction smells:
• Duplicate Abstraction
• Imperative Abstraction
• Multifaceted Abstraction
• U...
Detected implementation smells
• Complex Conditional
• Complex Method
• Duplicate Code
• Empty Catch Block
• Long Identifi...
Mining GitHub C# repositories
Repositories 1,988
Number	of	types 436,832
Number	of	methods 2,265,971
Lines	of	Code	(C#) 49...
RQ1. Frequency of smells
RQ1. What is the distribution of design and
implementation smells in C# code?
Unutilized	Abstraction 90,786
Duplicate	Abst...
RQ1. What is the distribution of design and
implementation smells in C# code?
Unutilized	Abstraction 90,786
Duplicate	Abst...
RQ1. What is the distribution of design and
implementation smells in C# code?
Magic	Number 2,993,353
Long	Statement 462,49...
RQ1. What is the distribution of design and
implementation smells in C# code?
Magic	Number 2,993,353
Long	Statement 462,49...
RQ2. Inter-category co-occurrence
RQ2. What is the relationship between the
occurrence of design smells and implementation
smells?
0 5 10 15 20
0
2
4
6
8
10...
RQ3. Intra-category co-occurrence
RQ3. Is the principle of coexistence applicable to
smells in C# projects?
𝐶 𝑠1, 𝑠2 =	
𝑛1	 ∗ 𝑛2
𝑁
RQ4. Smell density and project size
RQ4. Does smell density depend on the size of the
C# repository?
0 50000 100000 150000 200000
020406080100
LOC
DesignSmell...
Each C# class that you work with, on average, has approximately
• 2 design smells (113*14.7/1000 = 1.67) and
• 6 implement...
House of Cards: Code Smells in Open-source C# Repositories
House of Cards: Code Smells in Open-source C# Repositories
Upcoming SlideShare
Loading in …5
×

House of Cards: Code Smells in Open-source C# Repositories

109 views

Published on

Slides presented at ESEM conference on Nov 10, 2017 at Toronto, Canada.

Published in: Software
  • Be the first to comment

  • Be the first to like this

House of Cards: Code Smells in Open-source C# Repositories

  1. 1. House of Cards: Code Smells in Open-source C# Repositories Tushar Sharma, Marios Fragkoulis, and Diomidis Spinellis Funded by SENECA project under Marie-Skłodowska Curie Actions
  2. 2. Code Smells …certain structures in the code that suggest (sometimes they scream for) the possibility of refactoring. - Kent Beck <!>
  3. 3. http://www.tusharma.in/smells/ A Taxonomy of Software Smells
  4. 4. Identified gap • Existing mining studies on smells lack • scale (Number of subject systems analyzed), and • breadth (Number of smells detected) • Solely performed on Java subject systems
  5. 5. Overview of the study Research questions 1988 open-source repositories Designite <!> 19 Design smells 11 Implementation smells Results
  6. 6. Detected design smells Abstraction smells: • Duplicate Abstraction • Imperative Abstraction • Multifaceted Abstraction • Unnecessary Abstraction • Unutilized Abstraction Encapsulation smells: • Deficient Encapsulation • Unexploited Encapsulation Modularization smells: • Broken Modularization • Cyclically-dependent Modularization • Hub-like Modularization • Insufficient Modularization Hierarchy smells: • Broken Hierarchy • Cyclic Hierarchy • Deep Hierarchy • Missing Hierarchy • Multipath Hierarchy • Rebellious Hierarchy • Unfactored Hierarchy • Wide Hierarchy
  7. 7. Detected implementation smells • Complex Conditional • Complex Method • Duplicate Code • Empty Catch Block • Long Identifier • Long Method • Long Parameter List • Long Statement • Magic Number • Missing Default • Virtual Method Call from Constructor
  8. 8. Mining GitHub C# repositories Repositories 1,988 Number of types 436,832 Number of methods 2,265,971 Lines of Code (C#) 49,303,314 Median LOC 4,391
  9. 9. RQ1. Frequency of smells
  10. 10. RQ1. What is the distribution of design and implementation smells in C# code? Unutilized Abstraction 90,786 Duplicate Abstraction 73,992 Unnecessary Abstraction 44,583 Imperative Abstraction 11,790 Multifaceted Abstraction 1,236 Deficient Encapsulation 30,214 Unexploited Encapsulation 6,964 Cyclically-dependent Modularization 52,436 Insufficient Modularization 26,429 Broken Modularization 15,624 Hub-like Modularization 676 Unfactored Hierarchy 20,962 Broken Hierarchy 20,332 Rebellious Hierarchy 11,794 Cyclic Hierarchy 4,342 Wide Hierarchy 3,140 Missing Hierarchy 2,598 Multipath Hierarchy 1,454 Deep Hierarchy 179
  11. 11. RQ1. What is the distribution of design and implementation smells in C# code? Unutilized Abstraction 90,786 Duplicate Abstraction 73,992 Unnecessary Abstraction 44,583 Imperative Abstraction 11,790 Multifaceted Abstraction 1,236 Deficient Encapsulation 30,214 Unexploited Encapsulation 6,964 Cyclically-dependent Modularization 52,436 Insufficient Modularization 26,429 Broken Modularization 15,624 Hub-like Modularization 676 Unfactored Hierarchy 20,962 Broken Hierarchy 20,332 Rebellious Hierarchy 11,794 Cyclic Hierarchy 4,342 Wide Hierarchy 3,140 Missing Hierarchy 2,598 Multipath Hierarchy 1,454 Deep Hierarchy 179
  12. 12. RQ1. What is the distribution of design and implementation smells in C# code? Magic Number 2,993,353 Long Statement 462,491 Complex Method 95,244 Long Parameter List 79,899 Missing Default 23,497 Complex Conditional 21,643 Duplicate Code 17,921 Long Method 17,521 Empty Catch Block 14,560 Long Identifier 7,741 Virtual Method Call from Constructor 4,545
  13. 13. RQ1. What is the distribution of design and implementation smells in C# code? Magic Number 2,993,353 Long Statement 462,491 Complex Method 95,244 Long Parameter List 79,899 Missing Default 23,497 Complex Conditional 21,643 Duplicate Code 17,921 Long Method 17,521 Empty Catch Block 14,560 Long Identifier 7,741 Virtual Method Call from Constructor 4,545 On average, one magic number smell per 16 lines of code!!
  14. 14. RQ2. Inter-category co-occurrence
  15. 15. RQ2. What is the relationship between the occurrence of design smells and implementation smells? 0 5 10 15 20 0 2 4 6 8 10 12 Design Smells ImplementationSmells 1 8 15 22 30 37 44 51 58 65 72 79 86 94 101 108 115 Counts Co-occurrence between smell instances ⍴ = 0.78 (p-value < 2.2e-16) Co-occurrence between smell types ⍴ = 0.80 (p-value < 2.2e-16) The results emphasize the need to pay attention to smells at all granularities.0 50 100 150 200 250 300 02004006008001000 Design Smells Implementationsmells
  16. 16. RQ3. Intra-category co-occurrence
  17. 17. RQ3. Is the principle of coexistence applicable to smells in C# projects? 𝐶 𝑠1, 𝑠2 = 𝑛1 ∗ 𝑛2 𝑁
  18. 18. RQ4. Smell density and project size
  19. 19. RQ4. Does smell density depend on the size of the C# repository? 0 50000 100000 150000 200000 020406080100 LOC DesignSmellsDensity 0 50000 100000 150000 200000 0100200300400500 LOC ImplementationSmellsDensity ⍴ = -0.25 (p-value < 2.2e-16) ⍴ = 0.27 (p-value < 2.2e-16)
  20. 20. Each C# class that you work with, on average, has approximately • 2 design smells (113*14.7/1000 = 1.67) and • 6 implementation smells (113*55.8/1000 = 6.2)

×