Bad Smells in Code Flashcards
What is the Duplicate Code Smell?
Same code structure in more then one place.
What is the Large Class Smell?
When a class is trying to do too much, it often shows up as too many instance variables. Another smell is too much code.
What is the Divergent Change Code Smell?
Divergent Change occurs when one class is commonly changed in different ways for different reasons. Any change to handle a variation should change a single class, and all the typing in the new class should express the variation.
What is the Shotgun Surgery Code smell?
When every time you make a kind of change, you have to make a lot of little changes to a lot of different classes.
What is the Feature Envy Code smell?
When a method seems more interested in a class other then the one it actually is in.
What is the Data Clumps Code smell?
Bunches of data that hang around together ought to be made into their own object.
What is the primitive obsession Code smell?
Reluctancy to use small objects for small tasks, such as money classes that combine number and currency,…
What is the switch statement code smell?
Avoid switch statements as they introduce duplication. Refactor to polymorphism.
What is the parallel Inheritance Hierarchies code smell?
Special case of shotgun surgery, every time you make a subclass of one class, you also have to make a subclass of another.
What is the Lazy Class code smell?
Each class you create costs money to maintain and understand. a class that isn’t doing enough to pay for itself should be eliminated.
What is the Speculative Generality Code Smell?
“ooh i think we need the ability to do this kind of thing someday” => complex code
What is the Temporary Field Code smell?
Sometimes you see an object in which an instance variable is set only in certain circumstances. such code is difficult to understand.
What is the message chain code smell?
Law of demeter, talk to friends not strangers.
What is the middle man code smell?
When you look at a cflass’s interface and find half the methods are delegating to this other class. After a while it is time to remove the middle man. a.k.a. too much delegation.
What is the inappropriate Intimacy Code smell?
Sometimes classes bnecome far too intimate and spend too much time delving in each others’ private parts.