Bad Smells in Code Flashcards

1
Q

What is the Duplicate Code Smell?

A

Same code structure in more then one place.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is the Large Class Smell?

A

When a class is trying to do too much, it often shows up as too many instance variables. Another smell is too much code.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is the Divergent Change Code Smell?

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What is the Shotgun Surgery Code smell?

A

When every time you make a kind of change, you have to make a lot of little changes to a lot of different classes.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What is the Feature Envy Code smell?

A

When a method seems more interested in a class other then the one it actually is in.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What is the Data Clumps Code smell?

A

Bunches of data that hang around together ought to be made into their own object.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What is the primitive obsession Code smell?

A

Reluctancy to use small objects for small tasks, such as money classes that combine number and currency,…

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What is the switch statement code smell?

A

Avoid switch statements as they introduce duplication. Refactor to polymorphism.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What is the parallel Inheritance Hierarchies code smell?

A

Special case of shotgun surgery, every time you make a subclass of one class, you also have to make a subclass of another.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What is the Lazy Class code smell?

A

Each class you create costs money to maintain and understand. a class that isn’t doing enough to pay for itself should be eliminated.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What is the Speculative Generality Code Smell?

A

“ooh i think we need the ability to do this kind of thing someday” => complex code

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What is the Temporary Field Code smell?

A

Sometimes you see an object in which an instance variable is set only in certain circumstances. such code is difficult to understand.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What is the message chain code smell?

A

Law of demeter, talk to friends not strangers.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What is the middle man code smell?

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What is the inappropriate Intimacy Code smell?

A

Sometimes classes bnecome far too intimate and spend too much time delving in each others’ private parts.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What is the alternative classes with different interfaces code smell?

A

Methods that do the same thing but have different signatures for what they do.

17
Q

What is the incomplete library class code smell?

A

When a library classes misses functionality. You need to introduce a foreign method or a local extension.

18
Q

What is the data class code smell?

A

Only fields and getter & setters for these fields. Where’s the logic?

19
Q

What is the refused bequest code smell?

A

Subclasses get to inherit the methods and data of their parents. But what if they don’t want or need what they are given? => Wrong hierarchy.

20
Q

What is the comments code smell?

A

Bad code needs lot of comments…