A Philosophy of Software Design Flashcards

1
Q

Why do you create classes and methods?

A

To abstract complexity. Abstraction hides complexity. There is no point in creating an interface or method if we are not hiding implementation details. Abstraction controls complexity by hiding it. Classes should have depth, shallow interfaces, and big implementation. Remember that side effects are part of an interface. Remember about the Unix file interface.

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

What should we do about exceptions?

A

Make exceptions disappear by changing the semantics of the code. Remember the about the meaning of the unset variable command and about the windows file vs Unix file mentioned in the talk.

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

Exceptions vs Return errors codes

A

Exceptions add more value if they travel far up the stack. If you are going to deal with the exception right after calling maybe an error code is better. E.g., dealing with a not found error in an API.

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

When throw exceptions vs redefine semantics?

A

You should throw if you can’t return what your signature says. E.g., file.read() should throw, “asf”.char_at(-1) should throw, “21444”.substring(-1, 17) could clip the range.

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

Tactical vs Strategical approach

A

Tactical approach focus on just getting it to work. The system turns into spaghetti really fast.

We MUST use Strategical approach were the goal is great design:

  • Reduce complexity
  • Simplify future development
  • Develop faster in the future
  • Spend extra time today, pays on the long run
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

General vs Specific classes

A

General -> Simpler and deeper
Specific -> Shallow

As the tests get more specific the code gets more generic.

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