Code Smells Flashcards

1
Q

Signs and indicators of future problems/issues in the source code. May cause the program to be hard to understand, maintain and extend.

A

Code Smells

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

Object-Orientation Abusers:

  • method or class is trying to exhibit too many behaviors
A

Too Many Switch Statements

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

Object-Orientation Abusers:

  • fields get their values only under certain circumstances, outside of these circumstances, they’re empty
  • refers to a field (variable) that is used only in certain situations or temporarily during execution
A

Temporary Field

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

Object-Orientation Abusers:

  • occurs when a subclass inherits from a parent class but does not use all of the methods and properties of the parent class
  • when subclass does not use members inherited from a superclass
A

Refused Bequest

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

Object-Orientation Abusers:

  • closely related classes should share the same interface, so they can be pluggable
  • two classes perform identical functions but have different method names
A

Alternative Classes with Different Interfaces

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

Bloaters:

  • a method contains too many lines of code
  • methods that are too long are difficult to understand, test, and maintain
A

Long Method

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

Bloaters:

  • a class that contains many fields/methods/lines of code
  • classes that are too large are difficult to understand, test, and maintain
A

Large Class

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

Bloaters:

  • occurs when developers overuse primitive data types, such as integers, strings, and booleans, to represent complex domain concepts
  • Using primitive instead of creating own classes
A

Primitive Obsession

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

Bloaters:

  • more than three or four parameters for a method
  • methods have too many parameters
A

Long Parameter List

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

Bloaters:

  • a group of data that always appear together
  • occurs when a group of related variables are passed around together in a clump throughout various parts of the program
A

Data Clumps

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

Change Preventers:

  • same class changed for different reasons
  • having to change many unrelated methods when you make changes to a class
A

Divergent Change

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

Change Preventers:

  • Several classes changed for every new feature/code
  • making any modifications requires that you make many small changes to many different classes
A

Shotgun Surgery

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

Change Preventers:

  • occurs when an inheritance tree depends on another inheritance tree by composition
A

Parallel Inheritance Hierarchies

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

Change Preventers:

  • code that is too difficult to change without breaking other parts of the codebase. This can make the code difficult to maintain and extend
A

Rigid Code

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

Dispensables:

  • occurs when a method is filled with explanatory comments
A

Unnecessary Comments

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

Dispensables:

  • is code that appears in multiple places in the codebase
  • when the same code is repeated multiple times in different parts of the application
A

Duplicate Code

17
Q

Dispensables:

  • occurs when a class is rarely used or has very little functionality
  • when a class doesn’t do much
A

Lazy Class

18
Q

Dispensables:

  • occurs when a class is defined primarily to hold data and lacks significant behavior or functionality
  • these are simply containers for data used by other classes.
A

Data Class

19
Q

Dispensables:

  • Unused code
  • a variable, parameter, field, method or class is no longer used (usually because it’s obsolete)
A

Dead Code

20
Q

Dispensables:

  • occurs when code is written to anticipate future needs that may not actually materialize
A

Speculative generality

21
Q

Couplers:

  • a method accesses the data of another object more than its own data
  • when a method excessively accesses the data of another class
A

Feature Envy

22
Q

Couplers:

  • when two classes are constantly accessing each other’s members
A

Inappropriate Intimacy

23
Q

Couplers:

  • occurs when the program asks an object to get another object
  • occurs when a class needs to call multiple methods on other classes to get to a particular piece of data or functionality
A

Message Chains

24
Q

Couplers:

  • occurs when a class or an object primarily delegates its work to other classes or objects, forwarding messages without adding any meaningful value of its own
A

Middle Man