Smells Flashcards

1
Q

Define Duplicated Code

A

Two code fragments look almost identical.

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

Define Long Method

A

A method contains too many lines of code. Generally, any method longer than ten lines should make you start asking questions.

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

Define Large class

A

A class contains many fields/methods/lines of code.

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

Define long parameter list

A

More than three or four parameters for a method.

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

define divergent change

A

You find yourself having to change many unrelated methods when you make changes to a class. For example, when adding a new product type you have to change the methods for finding, displaying, and ordering products.

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

define shotgun surgery

A

Making any modifications requires that you make many small changes to many different classes.

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

define feature envy

A

A method accesses the data of another class more than its own.

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

define data clumps

A

Sometimes different parts of the code contain identical groups of variables (such as parameters for connecting to a database). These clumps should be turned into their own classes.

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

define primitive obsession

A

Use of primitives instead of small objects for simple tasks (such as currency, ranges, special strings for phone numbers, etc.)

Use of constants for coding information (such as a constant USER_ADMIN_ROLE = 1 for referring to users with administrator rights.)

Use of string constants as field names for use in data arrays.

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

define switch statements

A

You have a complex switch operator or sequence of if statements.

Fowler: using switch statements on type of object when you should be using subclasses/polymorphism

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

define lazy class

A

Understanding and maintaining classes always costs time and money. So if a class doesn’t do enough to earn your attention, it should be deleted.

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

define speculative generality

A

There’s an unused class, method, field or parameter.

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

define message chains

A

In code you see a series of calls resembling $a->b()->c()->d()

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

define middle man

A

If a class performs only one action, delegating work to another class, why does it exist at all?

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

define inappropriate intimacy

A

One class uses the internal fields and methods of another class.

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

define data class

A

A data class refers to a class that contains only fields and crude methods for accessing them (getters and setters). These are simply containers for data used by other classes. These classes don’t contain any additional functionality and can’t independently operate on the data that they own.

17
Q

define refused bequest

A

If a subclass uses only some of the methods and properties inherited from its parents, the hierarchy is off-kilter. The unneeded methods may simply go unused or be redefined and give off exceptions.

18
Q

define comments

A

A method is filled with explanatory comments.