Software Refactoring & Migration Flashcards

1
Q

What is refactoring?

A

“a change made to the internal structure of software to make it easier to UNDERSTAND and cheaper to MODIFY without changing the observable behaviour”

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

Examples of code changes?

A
  1. RENAMING a method or class
  2. Moving a METHOD up to a superclass or down to a subclass
  3. Moving a METHOD to a different class
  4. Converting a variable into a CONSTANT
  5. Converting a LOCAL (method) variable into a FIELD (class variable)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Importance of testing in refactoring?

A

We must start in a good state and remain in that state after the refactoring has been done.

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

Refactoring workflow?

A
Run test (start from known good state)
Refactor
Run tests (finish in same known good state)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What is a code smell?

A

“any characteristic in the source code of a program that possibly indicates a deeper problem”

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

What is Software Migration?

A

Move (i.e migrate) some functionality from one context to another (like refactoring with a bigger scope)

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

Examples of Software Migration

A
  1. System on files -> DBMS
  2. plain text communication -> encrypted communication
  3. proprietary statistical analysis library -> SPSS
  4. hosted system -> cloud
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Describe the software migration process

A
  1. Ensure behaviour is tested
  2. Migrate tests (initially may fail)
  3. gradually migrate functionality
  4. finish when all tests pass
  5. get rid of old tests
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What is a magic number?

A

A number that has IMPORTANT MEANING for the code but it’s not clear

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

How do we refactor frequent literals or magic numbers?

A

Extract Constant

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

How do we refactor long methods?

A

Extract Methods

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

Why are excessive comments a code smell?

A
  • too many means code might not be of the highest quality

- they age and grow OUT OF STEP with the changing code

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

How to refactor code with excessive comments?

A

Extract Method

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