Final Flashcards Preview

CPSC 310 > Final > Flashcards

Flashcards in Final Deck (16)
Loading flashcards...
1
Q

What are advantages of modularity?

A

Advantages of Modularity: - Minimizes Complexity - Reusability - Extensibility - Portability - Maintanability

2
Q

What does SOLID stand for?

A

SOLID is a combination of principles: S - Solid Responsibility Principle O - Open/Closed Principle L - Liskov Substitution Principle I - Interface Segregation Principle D - Dependency Inversion Principle

3
Q

State the single responsibility principle.

A

Single responsibility principle: a class should have only a single responsibility.

4
Q

What is cohesion?

A

Cohesion refers to how closely the functions in a module are related.

5
Q

What is cohesion?

A

Cohesion refers to how closely the functions in a module are related.

6
Q

The Or-check.

A

A class description that describes a class in terms of alternatives is probably not a class but a set of classes.

7
Q

Name 7 types of cohesion.

A

1) Coincidental cohesion (bad)
2) Logical cohesion (bad)
3) Temporal cohesion
4) Procedural cohesion
5) Communicational cohesion
6) Sequential cohesion (very good)
7) Functional cohesion (best)

8
Q

What is the advantage and disadvantage of functional cohesion?

A

Functional cohesion.

Advantage: Cohesive objects are easy to reuse and understand.

Disadvantage: Functionally cohesive objects can proliferate and get very tiny.

9
Q

What does coupling do?

A

Coupling assesses how tightly a module is related to other modules. Goal is loose coupling - modules should depend on as few other modules as possible.

10
Q

Name 9 types of coupling.

A

Types of Coupling:

  1. Content Coupling (high)
  2. Stamp Coupling (Data-structured coupling)
  3. Common Coupling
  4. Data Coupling
  5. External Coupling
  6. Message Coupling (low)
  7. Control Coupling
  8. No Coupling
  9. Semantic Coupling
11
Q

Desine semantic coupling.

A

Semantic coumpling is the most insidious kind of coupling, occurs when one module makes use not of some syntactic element of another module but of some semantic knowledge of another module’s inner workings.

12
Q

Why is semantic coupling dangerous?

A

Semantic coupling is dangerous because changing code in the used module can break code in the using module in ways that are completely undetectable by the compiler. When code like this breaks, it breaks in subtle ways that seem unrelated to the change made in the used module, which turns debugging into a Sisyphean task.

13
Q

State the open/closed principle.

A

A class must be closed for internal change, but must be open for extensions.

14
Q

State the Liskov Substitution Principle.

A

Liskov Substitution Principle:

If S is a subtype of T, then objects of type T in a program may be replaced with objects of type S without altering any of the desirable properties of that program.

  • Subclass has same or weaker preconditions
  • Subclass has same or stronger postconditions
15
Q

State the Interface Segregation Principle.

A

Interface Segregation Principle:

No client should be forced to depend on methods it does not use. Clients need only know about the methods that are of interest to them

16
Q

State the Dependency Inversion Principle.

A

Dependency Inversion Principle:

  1. High-level modules should not depend on lowlevel modules. Both should depend on abstractions.
  2. Abstractions should not depend on details. Details should depend on abstractions.