Chapter 2 Flashcards

1
Q

TRUE

A

Code that is Transparent, Reasonable, Usable, and Exemplary.

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

Determine what a class should do?

A

If the simplest description you can devise uses the word “and,” the class likely has more than one responsibility. If it uses the word “or,” then the class has more than one responsibility and they aren’t even very related.

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

Cohesion?

A

When everything in a class is related to its central purpose, the class is said to be highly cohesive or to have a single responsibility.

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

Cohesion?

A

When everything in a class is related to its central purpose, the class is said to be highly cohesive or to have a single responsibility.

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

Struct?

A

In Ruby it’s easy to separate structure from meaning. Just as you can use a method to wrap an instance variable, you can use the Ruby Struct class to wrap a structure.

Wheel = Struct.new(:rim, :tire)

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

Struct?

A

A convenient way to bundle a number of attributes together, using accessor methods, without having to write an explicit class.

Wheel = Struct.new(:rim, :tire)

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

Summary

A

The path to changeable and maintainable object-oriented software begins with classes that have a single responsibility. Classes that do one thing isolate that thing from the rest of your application. This isolation allows change without consequence and reuse without duplication.

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