Exam 1

0.0(0)
Studied by 0 people
call kaiCall Kai
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/211

encourage image

There's no tags or description

Looks like no tags are added yet.

Last updated 7:41 PM on 3/28/26
Name
Mastery
Learn
Test
Matching
Spaced
Call with Kai

No analytics yet

Send a link to your students to track their progress

212 Terms

1
New cards

Design is about:

making change safe and affordable over time.

2
New cards

Most software cost is in:

modifying code, not writing it

3
New cards

Why use namespaces from a design perspective?

To organize modules into conceptual boundaries (e.g, TeaShop.Payments, TeaShop.Inventory, TeaShop.UI)

4
New cards

UML class diagrams show:

static structure (not execution flow)

5
New cards

T/F: Multiplicity is a design constraint that must be enforced in code.

True

6
New cards

What is the underlying premise of SRP?

SRP is about one actor (source of change) per module. Actors represent change pressure, not specific people.

7
New cards

What does this mean? SRP applies fractally from class to system level.

A fractal is a pattern that repeats at different scales.

Like a tree:

  • branches look like small trees; same rule just zoomed in/out.

The SRP rule applies to every level of the system.

8
New cards

Define Strategy Pattern:

A pattern that defines a family of algorithms, encapsulates each, and makes them interchangeable at runtime.

9
New cards

What is one benefit of the Strategy Pattern?

It prevents "God methods" where multiple behaviors are tangled together. If done well, follows OCP, SRP, and permits dynamic dispatching.

10
New cards

What is the Open-Closed Principle?

OCP is about localizing change: "open for extension, closed for modification."

  • Extend behavior without modifying stable code.

  • SRP required → cannot close a class that has multiple reasons to change.

11
New cards

What does the Liskov Substitution Principle require from subtypes?

  • Subtypes must not:

    • strengthen preconditions,

    • weaken postconditions, and

    • must preserve invariants.

12
New cards

T/F: LSP is the safety foundation for polymorphism and OCP.

True

13
New cards

What is the primary cause of software problems and maintenance cost?

complexity

14
New cards

Define complexity.

Anything related to the structure of a software system that makes it hard to understand or modify.

15
New cards

How does complexity manifest?

As change amplification, cognitive load, or unknown knowns.

16
New cards

What causes compexity?

dependencies: code cannot be modified / understood in isolation

obscurity: important information is not obvious (ambiguous naming of variables, inconsistencies)

17
New cards

What can highlight change amplification?

SRP

18
New cards

Define tactical programming

method to programming in which the focus is on getting it to work now (optimizing speed) without consideration of the consequences of the complexity introduced.

19
New cards

Define strategic programming

method to programming that encourages an investment mindset in which investments are both proactive and reactive and take about 10-20% of the programming time; leads to good design that optimizes long-term simplicity

20
New cards

T/F: OCP is framed as a refactoring discipline, not day-one over-design.

True

21
New cards

The best modules:

Have interfaces simpler than their implementations.

22
New cards

Define information hiding:

  • Each module should hide design decisions and internal details that are likely to change.

  • Public interfaces should be stable; internal representations should be free to evolve.

23
New cards

What should be hidden?

Details about how a module is implemented.

24
New cards

T/F: Encapsulation is most valuable when it hides volatility.

True

25
New cards

Define information leakage.

When modules understand the internal design logic of other modules.

26
New cards

Define temporal decomposition

When the structure of system is designed on time order and not by concept (rule/policy). This leads to information leakage as modules must know the details versus simply follow instructions.

27
New cards

How to overcome temporal decomposition?

Create a class that owns the rule/policy and has instruction methods that may be invoked by other methods (hint: order specialist class w/ methods: getPattyInstructions, getSauces, etc.)

28
New cards

When do you use an interface vs a class?

Interface: Anticipate change; Class: Anticipate no changes

29
New cards

Define pass-through method.

method that does little more than invoke another method

30
New cards

Define dispatcher

a valid form of pass-through method in which the method performs logic to determine which specific method should be invoked.

31
New cards

What is a context object? Why?

An object that bundles a list of variables (often global) to reduce complexity; preferred over long parameter lists of pass-through variables

32
New cards

Explain the notion of “pull complexity downward”.

It is more important for a module to have a simple interface than implementation. We want to pull complexity down into the module anytime:

  1. the complexity is closely related to the class’s existing functionality, and

  2. the complexity will lead to simplifications elsewhere, and

  3. the complexity will lead to a simpler interface

33
New cards

Define composition root pattern.

Pattern in which a place is designated within the program for wiring together components and creation of objects. This helps keep the main program short and boring.

34
New cards

What is allowed in LSP? What is not allowed?

Allowed: different implementation, extra behavior, performance changes

Forbidden: different meaning, changes to guarantees, semantic changes (changes to method outcome but not signature, params)

35
New cards

T/F: A well-designed system has each layer providing a different level of abstraction compared to the ones above/below it.

True

36
New cards

Explain how leaky abstractions and redundant layers increase cognitive load.

Each layer should represent one realm of thought. If understanding code requires reasoning about multiple layers at once, cognitive load increases.

37
New cards

What is the intent of the strategy pattern?

Encapsulate interchangeable algorithms behind a stable interface and swap them at runtime.

38
New cards

How does the strategy pattern uphold SRP, OCP, LSP?

  • SRP: Isolates each algorithm into its own class

  • OCP: Lets you add new algorithms without editing the context

  • LSP: Relies on consistent behavior from each strategy implementation

39
New cards

What is the intent of the decorator pattern?

Add responsibilities by wrapping objects rather than modifying or subclassing them repeatedly.

40
New cards

How does the decorator pattern uphold SRP, OCP, LSP?

  • SRP: Keeps each added responsibility in its own class

  • OCP: Composes new behavior without changing existing components

  • LSP: Requires that decorators preserve the component contract

41
New cards

Strategy Pattern vs Decorator Pattern

  • Strategy: only one thing varies; uses a context with one selected strategy;

  • Decorator: stack additional behaviors around the same base operation; many things to vary; uses wrapper chains.

  • Common trap: using Strategy when you really need behavior layering (logging + retry + metrics), or using Decorator when you only need one policy choice.

42
New cards

Dependency vs Association vs Composition

  • Dependency: temporary method-level usage (local variable).

  • Association: long-lived reference between objects.

  • Composition: strong ownership where part lifetime is bound to whole.

  • Common trap: drawing composition when the part is actually supplied externally and can outlive the owner (that is aggregation/association, not composition).

43
New cards

SRP vs DRY

  • SRP focuses on change boundaries (one actor/reason to change).

  • DRY focuses on duplication removal.

  • Rule of thumb: when they conflict, prioritize clear responsibility boundaries first, then remove duplication safely.

44
New cards

Define Inheritance

Is structural and type-level (compile-time); models an is-a relationship where a subtype extends a base class enabling reuse of base behavior/state.

Notation: solid line, upward open triangle

45
New cards

Define Realization

A structural and type-level (compile-time) is-a relationship showing a class implementing an interface contract.

Notation: dashed line, upward open triangle

46
New cards

Define Dependency

Is non-structural (usage) and runtime/temporary; it is a short-lived relationship during execution, usually via parameters or local variables. It is not an is-a or has-a relationship.

Notation: dashed lined, downward arrow

47
New cards

Define Association

Is structural and state-level (runtime); is a long-lived has-a relationship in which objects know about each other but no ownership is implied.

Notation: Solid line, downward arrow

48
New cards

T/F: Prefer Association over Aggregation and Composition unless instance lifetime must be explicitly defined.

True

49
New cards

Define Aggregation

Is structural and state-level (runtime); it is a has-a whole-part relationship where the part's lifetime is independent of the whole. (weak ownership - groups)

Notation: solid line, open diamond

50
New cards

Define Composition

Is structural and state-level (runtime); it is a strong has-a relationship where the part is created internally and lifetimes are bound. (strong ownership)

Notation: solid line, filled diamond

51
New cards

Abstraction

Hiding irrelevant details to reduce cognitive load and localize change.

52
New cards

Abstract class

Partially implemented base type that can share state/behavior but cannot be instantiated.

53
New cards

Actor (SRP)

Conceptual source of change that requests modifications to code.

54
New cards

Behavioral subtyping

LSP rules for preconditions, postconditions, and invariants.

55
New cards

Change amplification

Small changes cause widespread edits/failures in several different areas of the code.

56
New cards

Cohesion

How tightly related a modules’s responsibilities are. Goal is high cohesion.

57
New cards

Concrete class

Instantiable type with full implementation.

58
New cards

Contract

The behavioral promises a type makes to its clients.

59
New cards

Coupling

Degree of dependency between modules. Desire is loose/low coupling.

60
New cards

Dynamic dispatch

Runtime selection of the correct overridden method.

61
New cards

Encapsulation

The process of protecting state and exposing controlled behavior.

62
New cards

Interface

Contract defining required members without implementation.

63
New cards

Multiplicity

UML constraint on how many related instances exist; must be enforced in code.

64
New cards

Polymorphism

Using a base type to work with many concrete types.

65
New cards

Precondition

What must be true before a method runs.

66
New cards

Postcondition

What must be true after a method completes.

67
New cards

Semantic promise

The meaning/behavior clients expect from a type.

68
New cards

Substitutability

Ability to replace a base type with any subtype safely.

69
New cards

UML class diagram

Static structural view of classes and relationships.

70
New cards

T/F: Refactor toward OCP only when variation appears.

True

71
New cards

Liskov Substitution Principle (LSP)

Subtypes must be usable anywhere their base type is expected without surprises. Focuses on semantics not syntax.

72
New cards

T/F: Design debt often causes maintenance pain and subtle defects after initial release.

TRUE

73
New cards

T/F: OOD techniques are primary used to localize changes as requirements evolve.

TRUE

74
New cards

T/F: A method that keeps growing with type-based conditions is a warning sign that the method needs refactoring.

TRUE

75
New cards

T/F: Dynamic dispatch means method behavior is resolved at compile time based on the concrete object behind an abstraction.

FALSE

76
New cards

T/F: If an object is only passed as a method parameter and never stored, the relationship should be modeled in UML as a dependency rather than an association.

TRUE

77
New cards

T/F: A class that changes frequently automatically violates the Single Responsibility Principle

FALSE

78
New cards

T/F: If accounting-rule changes and database changes keep hitting the same class, that is a strong SRP refactoring signal.

TRUE

79
New cards

T/F: Replacing repeated policy if/else branches with Strategy can support safer extension.

TRUE

80
New cards

T/F: OCP means existing code should never be modified under any circumstances.

FALSE

81
New cards

T/F: In the Decorator pattern, once decorators are introduced, the concrete component should no longer be used directly by clients.

FALSE

82
New cards

T/F: Creating an interface with exactly one implementation and no variation evidence is always a discipline OCP decision.

FALSE

83
New cards

T/F: ThrowingNotSupportedException from an override for required base behavior is often a sign of LSP trouble.

TRUE

84
New cards

T/F: A God class never exhibits high cohesion.

TRUE

85
New cards

In long-lived systems, which activity usually dominates total cost?

A. Writing the first working version.

B. Changing and extending existing behavior over time

C. Choosing the IDE and formatter

D. Renaming local variables after code review

B

86
New cards

Which statement about abstract classes is correct?

A. They cannot define constructors.

B. They can share implementation and still be non-instantiable.

C. They prevent derived classes from overriding behavior.

D. They are identical to interfaces.

B

87
New cards

An array IPublication[] holding instances of PaperbackBook, Magazine, and AudioBook demonstrates:

A. Immutability

B. Inheritance reuse of implementation

C. Polymorphism through a shared contract

D. Static method binding at compile time

C

88
New cards

When ownership and lifetime semantics are not essential to an instance, the recommendation is:

A. Association

B. Composition

C. Aggregation

D. Realization

A

89
New cards

In actor-based SRP analysis, the most useful question is:

A. What layer of the architecture does this class belong to?

B. How cohesive are the methods within this class?

C. Who requests this kind of change?

D. How frequently is this class modified?

C

90
New cards

SRP-first guidance for DRY decisions is:

A. Always deduplicate any similar code.

B. Never deduplicate across files.

C. Prefer inheritance before deduplication review.

D. Deduplicate only when the code changes for the same reason.

D

91
New cards

Practical OCP Primarily aims to:

A. Eliminate all future maintenance.

B. Predict every future requirement up front.

C. Protect stable code by localizing where new behavior lands.

D. Replace every class with an interface.

C

92
New cards

You have a Print class whose constructor requires six concrete classes to perform a single operation. This most strongly suggests:

A. The Print class is optimized for unit testing because dependencies are replaceable.

B. The Print class likely violates SRP.

C. The Print class is open for extension and closed for modification.

D. The Print class should be made static to reduce dependencies.

B

93
New cards

Define The Interface Segregation Principle (ISP)

A client should not be forced to depend on interfaces they do not use.

94
New cards

T/F: Broad interfaces couple unrelated change axes, increasing recompilation, retesting, and regression risk.

TRUE

95
New cards

T/F: Interface design should follow usage boundaries, not implementation convenience.

TRUE

96
New cards

Signs of ISP Violations:

  • Class is forced to implement unrelated methods.

  • Clients depend on operations they should never call.

  • Dependency injection can accidentally wire a type that compiles but fails at runtime.

  • Small interface changes trigger broad ripple effects across unrelated clients.

97
New cards

SRP vs ISP

Boundary clarification: SRP asks what independent reasons-tochange exist inside a module; ISP asks what each client is forced to depend on at the module boundary.

98
New cards

How are ISP and OCP connected?

OCP depends on stable abstractions. Fat interfaces are unstable because unrelated client needs keep changing them. With ISP, you extend behavior by adding new focused contracts instead of modifying broad ones.

99
New cards

How are ISP and LSP connected?

  • LSP requires safe substitution. When a subtype throws on valid interface methods, substitution breaks.
    ISP: interface is too broad for some clients.
    LSP: subtype cannot honor full contract semantics.

100
New cards

How do Fat Interfaces impact Information Hiding?

Fat interfaces often leak internal workflow stages and implementation details. ISP pushes us to hide internals and expose only what a client must know.

Explore top notes

note
european expansion and exploration
Updated 1082d ago
0.0(0)
note
Chemistry Notes
Updated 789d ago
0.0(0)
note
Jobs in German (formation)
Updated 1154d ago
0.0(0)
note
Biostatistics, Chapters I & II
Updated 1272d ago
0.0(0)
note
3.4: Controversies
Updated 334d ago
0.0(0)
note
Vocal Music in Two Worlds
Updated 1371d ago
0.0(0)
note
european expansion and exploration
Updated 1082d ago
0.0(0)
note
Chemistry Notes
Updated 789d ago
0.0(0)
note
Jobs in German (formation)
Updated 1154d ago
0.0(0)
note
Biostatistics, Chapters I & II
Updated 1272d ago
0.0(0)
note
3.4: Controversies
Updated 334d ago
0.0(0)
note
Vocal Music in Two Worlds
Updated 1371d ago
0.0(0)

Explore top flashcards

flashcards
vocab words
184
Updated 474d ago
0.0(0)
flashcards
HL Bio C1 Free Response
20
Updated 1115d ago
0.0(0)
flashcards
APWH Cumulative Vocab List 2023
305
Updated 1058d ago
0.0(0)
flashcards
Greek Etyma Week 27
29
Updated 238d ago
0.0(0)
flashcards
ANSC Equipment
31
Updated 1135d ago
0.0(0)
flashcards
Eutropius High Frequency Vocab
147
Updated 219d ago
0.0(0)
flashcards
ECON-2302: Unit 1 Test
53
Updated 415d ago
0.0(0)
flashcards
vocab words
184
Updated 474d ago
0.0(0)
flashcards
HL Bio C1 Free Response
20
Updated 1115d ago
0.0(0)
flashcards
APWH Cumulative Vocab List 2023
305
Updated 1058d ago
0.0(0)
flashcards
Greek Etyma Week 27
29
Updated 238d ago
0.0(0)
flashcards
ANSC Equipment
31
Updated 1135d ago
0.0(0)
flashcards
Eutropius High Frequency Vocab
147
Updated 219d ago
0.0(0)
flashcards
ECON-2302: Unit 1 Test
53
Updated 415d ago
0.0(0)