lec 36: structural design patterns, part 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/38

encourage image

There's no tags or description

Looks like no tags are added yet.

Last updated 10:10 PM on 4/13/26
Name
Mastery
Learn
Test
Matching
Spaced
Call with Kai

No analytics yet

Send a link to your students to track their progress

39 Terms

1
New cards

What are structural design patterns concerned with?

How classes and objects are composed into larger structures.

2
New cards

What are the two broad types of structural patterns?

Class structural and object structural.

3
New cards

What pattern is the focus of this deck?

Adapter.

4
New cards
5
New cards

What problem does the Adapter pattern solve?

It lets classes work together when their interfaces are incompatible.

6
New cards

What is the definition of Adapter?

Adapter converts the interface of a class into another interface clients expect.

7
New cards

When should Adapter be used?

When you want to use an existing class but its interface does not match what the client needs.

8
New cards
9
New cards

In the DVR example, what is the main issue?

Different DVR manufacturers provide different interfaces for similar operations.

10
New cards

What are the three DVR libraries in the slides?

CiscoDvr, SonyDvr, and TivoDvr.

11
New cards

Why is the giant if/else solution bad?

Because client code becomes messy and tightly coupled to concrete DVR implementations.

12
New cards
13
New cards

What is the Target in the Adapter pattern?

The interface the client expects.

14
New cards

What is the Adaptee in the Adapter pattern?

The existing class with the incompatible interface.

15
New cards

What is the Adapter in the Adapter pattern?

The class that translates between the Target and the Adaptee.

16
New cards
17
New cards

What is the common target interface in the slides?

Dvr.

18
New cards

What methods does the Dvr interface provide?

play(h, m, s), stop(), and pause().

19
New cards

What adapter classes are shown in the slides?

CiscoDvrAdapter, SonyDvrAdapter, and TivoDvrAdapter.

20
New cards
21
New cards

What does CiscoDvrAdapter::play do?

It converts h/m/s into a Time object and calls beginPlayBack.

22
New cards

What does SonyDvrAdapter::play do?

It converts h/m/s into total seconds and calls startPlayback(seconds).

23
New cards

What does TivoDvrAdapter::play do?

It forwards the values directly to playFrom(h, m, s).

24
New cards
25
New cards

Why is Adapter useful in the DVR example?

It lets the same client code work with Cisco, Sony, or Tivo DVRs through one common interface.

26
New cards

What does the client code interact with after adaptation?

The Target interface, not the concrete adaptee classes.

27
New cards
28
New cards

What is a class adapter?

An adapter that uses inheritance.

29
New cards

What is an object adapter?

An adapter that uses composition.

30
New cards

What does the deck’s class adapter inherit from publicly?

The target interface Dvr.

31
New cards

What does the deck’s class adapter inherit from privately?

The concrete adaptee class.

32
New cards
33
New cards

What is one advantage of class adapter?

Only one object is involved and there is no extra pointer indirection.

34
New cards

What is one disadvantage of class adapter?

It is tied to a specific adaptee class.

35
New cards

What is one advantage of object adapter?

It can work with an adaptee and its subclasses.

36
New cards

What is one disadvantage of object adapter?

It is harder to override adaptee behavior.

37
New cards
38
New cards

What is the key exam phrase for Adapter?

Convert one interface into another interface the client expects.

39
New cards

What is a simple memory trick for Adapter?

Target is what the client wants, Adaptee is what you have, Adapter is the translator.