# Google Developers Day US - Python Design Patterns

18 cards · GoogleDeveloperDay · 2026-11-27

Video: <https://www.youtube.com/watch?v=0vJJlVBVTFg>

## Facade forces and what counts as a pattern [▶ 0:00](https://www.youtube.com/watch?v=0vJJlVBVTFg&t=0s)

**1.** In this talk, what two forces make a rich subsystem painful for both client authors and subsystem maintainers?

> Clients must confront unbridled complexity; maintainers cannot change exposed APIs without breaking clients.
>
> Aha · [▶ 1:08](https://www.youtube.com/watch?v=0vJJlVBVTFg&t=68s) · #facade #structural

**2.** What does the Facade pattern interpose between clients and a complex subsystem?

> A simple object or class that exposes only the subset of functionality clients need and delegates internally to the subsystem.
>
> How it works · [▶ 2:08](https://www.youtube.com/watch?v=0vJJlVBVTFg&t=128s) · #facade

**3.** According to the speaker, what four ingredients does a design pattern summary include?

> A frequent design problem, a solution structure with pros/cons and alternatives, and a **name** for shared vocabulary.
>
> Word to know · [▶ 3:08](https://www.youtube.com/watch?v=0vJJlVBVTFg&t=188s) · #gof

## GoF families and Python composition idioms [▶ 7:14](https://www.youtube.com/watch?v=0vJJlVBVTFg&t=434s)

**4.** How does the Gang of Four taxonomy divide patterns into three families?

> **Creational** (instantiation), **structural** (composition), **behavioral** (interaction and responsibility distribution).
>
> Word to know · [▶ 7:14](https://www.youtube.com/watch?v=0vJJlVBVTFg&t=434s) · #taxonomy

**5.** Why does the speaker treat duck typing and object composition as prerequisites before naming patterns?

> Program to an interface (duck typing) and favor **object composition** over class inheritance (hold/wrap idioms).
>
> Aha · [▶ 8:16](https://www.youtube.com/watch?v=0vJJlVBVTFg&t=496s) · #python #idioms

## Composition and creational patterns [▶ 10:00](https://www.youtube.com/watch?v=0vJJlVBVTFg&t=600s)

**6.** Hold vs wrap: which exposes internal structure to clients and which keeps coupling thin via delegation?

> **Hold** couples clients to the held sub-object (`o.s.method`). **Wrap** hides the wrappee and delegates so clients see only `o.method`.
>
> Aha · [▶ 11:05](https://www.youtube.com/watch?v=0vJJlVBVTFg&t=665s) · #composition

**7.** Why does calling `Fu()` in Python already resemble a factory without a separate pattern?

> If `Fu` is a class it constructs; if `Fu` becomes a callable function, callers need not change—flexibility without `new` syntax.
>
> How it works · [▶ 14:11](https://www.youtube.com/watch?v=0vJJlVBVTFg&t=851s) · #creational #python

**8.** Why does the speaker rename Singleton "Highlander," and what inheritance conflict does he describe?

> "There can be only one" instance; subclassing breaks when a `Bar` subclass of singleton `Foo` must also be that same `Foo` instance.
>
> Aha · [▶ 17:14](https://www.youtube.com/watch?v=0vJJlVBVTFg&t=1034s) · #singleton

**9.** How does the Borg (Monostate) pattern share state across many instances in Python?

> Replace each instance's `__dict__` with a **class-level shared dict** so identity differs but mutations are visible everywhere.
>
> How it works · [▶ 18:15](https://www.youtube.com/watch?v=0vJJlVBVTFg&t=1095s) · #borg #singleton

## Dependency injection and structural adapters [▶ 20:00](https://www.youtube.com/watch?v=0vJJlVBVTFg&t=1200s)

**10.** Why does the speaker say passing dependencies in from outside makes testing easier?

> Don't construct dependents inside a class—pass them in from outside—so tests can substitute fakes more easily.
>
> Word to know · [▶ 20:01](https://www.youtube.com/watch?v=0vJJlVBVTFg&t=1201s) · #creational

**11.** Adapter vs Facade: what is each primarily about?

> **Adapter** tweaks or translates an interface (often one object). **Facade** simplifies an overly rich subsystem to a needed subset (often many classes).
>
> Aha · [▶ 27:08](https://www.youtube.com/watch?v=0vJJlVBVTFg&t=1628s) · #structural

**12.** In the toy adapter example, how does a wrapper turn required `foo_bar(foo, bar)` into supplier `bar_foo(bar, foo)`?

> Hold the supplier in an attribute and implement `foo_bar` by calling `bar_foo` with arguments **swapped**.
>
> Only here · [▶ 23:05](https://www.youtube.com/watch?v=0vJJlVBVTFg&t=1385s) · #adapter

**13.** When is a mixin-style adapter class meant to be used instead of instantiated alone?

> Multiply inherit it with the class that supplies the mismatched method so one adaptation serves many concrete types.
>
> How it works · [▶ 24:06](https://www.youtube.com/watch?v=0vJJlVBVTFg&t=1446s) · #adapter #mixin

## Self-delegation and hook methods [▶ 28:12](https://www.youtube.com/watch?v=0vJJlVBVTFg&t=1692s)

**14.** Why does the speaker prefer "self-delegation" over "Template Method"?

> "Template" is overloaded (C++, HTML, etc.); self-delegation describes a base-class facet delegating hook work to a subclass facet of the same object.
>
> Aha · [▶ 28:12](https://www.youtube.com/watch?v=0vJJlVBVTFg&t=1692s) · #behavioral

**15.** In the Template Method / self-delegation structure, what roles do the organizing method and hook methods play?

> The **organizing method** in the base class runs the workflow; **hook methods** in concrete subclasses supply variable steps.
>
> How it works · [▶ 30:01](https://www.youtube.com/watch?v=0vJJlVBVTFg&t=1801s) · #template-method

**16.** In `cmd.Cmd`, what does `cmdloop` exemplify about frameworks?

> It is the **organizing logic** (input → precmd → command → postcmd) while subclasses supply concrete hooks—the "Hollywood principle" (don't call us, we'll call you).
>
> Only here · [▶ 32:04](https://www.youtube.com/watch?v=0vJJlVBVTFg&t=1924s) · #framework #stdlib

**17.** In `queue.Queue.put`, why is `_put` a hook while `put` is the organizing method?

> `put` handles synchronization and waiting; `_put` only appends to the internal deque—so you can change queuing discipline without reimplementing thread safety.
>
> Only here · [▶ 36:09](https://www.youtube.com/watch?v=0vJJlVBVTFg&t=2169s) · #stdlib #threading

## Q&A: patterns in Python [▶ 40:00](https://www.youtube.com/watch?v=0vJJlVBVTFg&t=2400s)

**18.** In Q&A, does the speaker claim any GoF pattern is especially **bad** in Python?

> No—patterns are typically **not needed** rather than harmful; mixin/multiple-inheritance patterns work in Python unlike Smalltalk's warning.
>
> Word to know · [▶ 41:01](https://www.youtube.com/watch?v=0vJJlVBVTFg&t=2461s) · #qa
