Style Flashcards

1
Q

The practice of rewriting existing code to improve its design is called ANSWER.

A

refactoring

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

ANSWER is the name of the code smell for when an instance method doesn’t rely on the state of the instance.

A

utility function

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

ANSWER is the name of the code smell for when the same two or three items frequently appear together in classes and parameter lists, or when a group of instance variable names start or end with similar substrings.

A

data clump

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

When you have two or three items that frequently appear together, the first step in fixing the problem is generally ANSWER.

A

put them in their own object

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

The code smell called ANSWER occurs when a code fragment references another object more often than it references itself.

A

feature envy

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

A popular Phil Karlton quote is: There are only two hard things in computer science - cache invalidation and ANSWER.

A

naming things

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

A class that publishes a getter or setter for an instance variable invites client classes to commit the code smell called ANSWER.

A

inappropriate intimacy

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

The prof thinks code should be broken into small pieces in order to make ANSWER easier.

A

re-using the code

Among other reasons

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

Scalastyle was originally flagging println as bad practice because in most production code, the usage of println you see is debug messages and people should be using ANSWER instead.

A

a logging package

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

The reason scalastyle complains about methods returning null can be seen by considering the type system of Scala. If I have a function that tests a parameter x to see if it is less than 3 and returns 2 if the test is true and null if the test is false, the type of the return value of the function would be ANSWER.

A

any

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

The reason scalastyle complains about methods using return also has to do with the type system of Scala. If in the Scala repl if I define a parameterless function f as equal to 3, then f is of type Int. However, if I instead define the function to be equal to return 3, I get an error message telling me that f ANSWER.

A

needs a result type

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