Code Smells

A Catalog of Wisdom about Hazards in Code — Python Edition

Art for Code Smells Check Out A Preview

By Joshua Kerievsky, Tim Ottinger

How do you distinguish great software design from poor software design? Code Smells go beyond vague programming principles by capturing industry wisdom about how not to design code. If you'd like to become skilled at Refactoring, you need to develop your ability to identify Code Smells. Study a collection of important Code Smells and compare each one to a simpler, cleaner design.

Highlights

Hazardous Designs
Hazardous Designs: Produce safer code by understanding a catalog of hazardous software designs. Learn more...
Integrated Forums
Integrated Forums: Ask questions, get expert replies and read fascinating discussions. Learn more...
Expert Videos
Expert Videos: Learn tools & techniques by watching short videos from industry experts. Learn more...

Includes

  • 4-6 hours of content
  • 156 pages
  • 22 Code Smells
  • 28 Quizzes
  • 3 Videos
  • Dozens of real-world examples
  • Finding smells in legacy code

Contents

You Are Here 3
Welcome to Code Smells 4
Connoisseurs of Code ← Click to Preview 5
How Sensitive Is Your Nose? 6
What Are Code Smells? 7
A Short History of Code Smells 8
Technical Debt 10
Credit Card Debt 11
Is Your Code in Debt? 12
What Does Technical Debt Look Like? ← Click to Preview 13
Decreasing Customer Responsiveness 14
Technical Debt at Two Organizations 15
Managing Technical Debt, A Short Quiz 16
Big Picture Cost of Technical Debt 17
Lost Intent 19
Lost Intent Example 20
Intention-Revealing Code 21
Losing Your Intention Survey 22
Inefficient Name 24
Optimizing Program(mer) Performance 25
The Goal: Reveal Intention ← Click to Preview 26
Perfect: Simple, Consistent, Accurate 27
Typing Is Not the Bottleneck 28
Fixing Inefficient Names 29
This or That Survey 30
Duplicated Code 32
Blatant Duplication 33
Subtle Duplication 34
Don’t Repeat Yourself 35
Duplicated Code Quiz 36
When is it Okay to Copy Code? 37
Deodorant Comment ← Click to Preview 39
Useless Comment 40
Comment Guidelines 41
Comment Quiz 42
A Comment Judgment Call 43
Other Deodorants 44
Long Method 46
Long Method Example 47
Long Method Makeover 48
What About Performance? 49
Why Do People Write Long Methods? 50
Long Method Survey 51
Large Class 53
Large Class Quiz 54
Dead Code 56
Removing Dead Code 57
Dead Code Example 58
Dead Code Survey ← Click to Preview 59
Lazy Class 61
How Lazy? 62
Baby Classes 63
Lazy Class Survey 64
Refactoring Common Smells 66
Oddball Solution 68
Oddball Solution Example 69
Majority Or Minority Oddball? 70
Oddball Solution Quiz 71
Primitive Obsession 73
Example: Repetitiveness 74
Example: Awkwardness 75
Primitive Obsession Survey 76
Switch Statement 78
Switch Statement Example 79
Replacing Switch Statements With Polymorphism 80
A False Case of a Switch Statement Smell 81
Maps Instead of Switch Statements 82
Switch Statement Quiz 83
Speculative Generality 85
Speculative Generality Example 86
Speculative Generality Quiz 87
Refactoring More Common Smells 89
Long Parameter List ← Click to Preview 91
Default Values & Better Alternatives 92
Conditional Complexity 94
Conditional Complexity Example 95
Conditional Complexity Solution 96
Conditional Complexity Sprawl 97
Conditional Complexity Quiz 98
Combinatorial Explosion 100
A Combinatorial Explosion of Methods 101
A Combinatorial Explosion of Classes 102
Combinatorial Explosion Quiz 103
Alternative Classes With Different Interfaces ← Click to Preview 105
An Example of Alternative Classes with Different Interfaces 106
Adapting a Class with a Different Interface 107
Inappropriate Intimacy 109
Inappropriate Intimacy Example 1 110
Inappropriate Intimacy Example 2 111
Inappropriate Intimacy Quiz 112
Indecent Exposure 114
Indecent Exposure Quiz 115
Refused Bequest 117
Refused Bequest Example 118
Refused Bequest Quiz 119
Black Sheep 121
Black Sheep Method Example 122
Data Class 124
When Are Data Classes Good? 125
Evolving Away From A Data Class 126
Solution Sprawl 128
Solution Sprawl Example 129
A Solution Sprawl Solution 130
Solution Sprawl Quiz 131
Feature Envy 133
Feature Envy Example ← Click to Preview 134
Feature Envy Quiz 135
Temporary Field 137
Temporary Field Example 138
Temporary Field Quiz 139
Side Effect 141
When Are Side Effects Ok? 142
Side Effect Example 143
Refactoring More Uncommon Smells Quiz 145
Dull Formatting 147
Follow The Masters - PEP8 148
Lousy Names 149
Overblown Solutions 150
Dull Formatting and Lousy Names Quiz 151
Scavenger Hunt Introduction 153
The Smells Scavenger Hunt 154
Conclusion - What’s Next? 156

Related Items

Volume Licensing

Have Any Questions?

Highlights

Hazardous Designs
Hazardous Designs: Produce safer code by understanding a catalog of hazardous software designs. Learn more...
Integrated Forums
Integrated Forums: Ask questions, get expert replies and read fascinating discussions. Learn more...
Expert Videos
Expert Videos: Learn tools & techniques by watching short videos from industry experts. Learn more...

Includes

  • 4-6 hours of content
  • 156 pages
  • 22 Code Smells
  • 28 Quizzes
  • 3 Videos
  • Dozens of real-world examples
  • Finding smells in legacy code

Contents

You Are Here 3
Welcome to Code Smells 4
Connoisseurs of Code ← Click to Preview 5
How Sensitive Is Your Nose? 6
What Are Code Smells? 7
A Short History of Code Smells 8
Technical Debt 10
Credit Card Debt 11
Is Your Code in Debt? 12
What Does Technical Debt Look Like? ← Click to Preview 13
Decreasing Customer Responsiveness 14
Technical Debt at Two Organizations 15
Managing Technical Debt, A Short Quiz 16
Big Picture Cost of Technical Debt 17
Lost Intent 19
Lost Intent Example 20
Intention-Revealing Code 21
Losing Your Intention Survey 22
Inefficient Name 24
Optimizing Program(mer) Performance 25
The Goal: Reveal Intention ← Click to Preview 26
Perfect: Simple, Consistent, Accurate 27
Typing Is Not the Bottleneck 28
Fixing Inefficient Names 29
This or That Survey 30
Duplicated Code 32
Blatant Duplication 33
Subtle Duplication 34
Don’t Repeat Yourself 35
Duplicated Code Quiz 36
When is it Okay to Copy Code? 37
Deodorant Comment ← Click to Preview 39
Useless Comment 40
Comment Guidelines 41
Comment Quiz 42
A Comment Judgment Call 43
Other Deodorants 44
Long Method 46
Long Method Example 47
Long Method Makeover 48
What About Performance? 49
Why Do People Write Long Methods? 50
Long Method Survey 51
Large Class 53
Large Class Quiz 54
Dead Code 56
Removing Dead Code 57
Dead Code Example 58
Dead Code Survey ← Click to Preview 59
Lazy Class 61
How Lazy? 62
Baby Classes 63
Lazy Class Survey 64
Refactoring Common Smells 66
Oddball Solution 68
Oddball Solution Example 69
Majority Or Minority Oddball? 70
Oddball Solution Quiz 71
Primitive Obsession 73
Example: Repetitiveness 74
Example: Awkwardness 75
Primitive Obsession Survey 76
Switch Statement 78
Switch Statement Example 79
Replacing Switch Statements With Polymorphism 80
A False Case of a Switch Statement Smell 81
Maps Instead of Switch Statements 82
Switch Statement Quiz 83
Speculative Generality 85
Speculative Generality Example 86
Speculative Generality Quiz 87
Refactoring More Common Smells 89
Long Parameter List ← Click to Preview 91
Default Values & Better Alternatives 92
Conditional Complexity 94
Conditional Complexity Example 95
Conditional Complexity Solution 96
Conditional Complexity Sprawl 97
Conditional Complexity Quiz 98
Combinatorial Explosion 100
A Combinatorial Explosion of Methods 101
A Combinatorial Explosion of Classes 102
Combinatorial Explosion Quiz 103
Alternative Classes With Different Interfaces ← Click to Preview 105
An Example of Alternative Classes with Different Interfaces 106
Adapting a Class with a Different Interface 107
Inappropriate Intimacy 109
Inappropriate Intimacy Example 1 110
Inappropriate Intimacy Example 2 111
Inappropriate Intimacy Quiz 112
Indecent Exposure 114
Indecent Exposure Quiz 115
Refused Bequest 117
Refused Bequest Example 118
Refused Bequest Quiz 119
Black Sheep 121
Black Sheep Method Example 122
Data Class 124
When Are Data Classes Good? 125
Evolving Away From A Data Class 126
Solution Sprawl 128
Solution Sprawl Example 129
A Solution Sprawl Solution 130
Solution Sprawl Quiz 131
Feature Envy 133
Feature Envy Example ← Click to Preview 134
Feature Envy Quiz 135
Temporary Field 137
Temporary Field Example 138
Temporary Field Quiz 139
Side Effect 141
When Are Side Effects Ok? 142
Side Effect Example 143
Refactoring More Uncommon Smells Quiz 145
Dull Formatting 147
Follow The Masters - PEP8 148
Lousy Names 149
Overblown Solutions 150
Dull Formatting and Lousy Names Quiz 151
Scavenger Hunt Introduction 153
The Smells Scavenger Hunt 154
Conclusion - What’s Next? 156

Related Items