← Graph

Duck Typing

concept 3 connections

Ruby technique where callers rely on whether an object responds to a given message rather than on its class. Krzywda uses it in his third aggregate implementation, guarding transitions with `raise :invalid unless issue.respond_to?(:...)`. Observes that duck typing is celebrated when learning Ruby but rarely or badly used in real codebases, and wonders whether controlled environments like state machines could make more principled use of it.

category
pattern
about
Duck Typing concept
Third implementation uses respond_to? checks as a duck-typing style of dispatch.
about
Duck Typing concept
FakeDice is justified with 'if it looks like a dice and rolls like a dice, it's a dice'.
about
Duck Typing concept
Discusses limits of duck typing and how to complement it with optional typing.

Provenance

Read by
8 extractions