Skip to content

feat: realistic domains for the six thinnest pythonic examples - #14

Merged
SuperElectron merged 1 commit into
stagingfrom
feat/richer-examples
Aug 27, 2026
Merged

feat: realistic domains for the six thinnest pythonic examples#14
SuperElectron merged 1 commit into
stagingfrom
feat/richer-examples

Conversation

@SuperElectron

Copy link
Copy Markdown
Owner

Follow-up to the catalog review: the six units whose pythonic.py was correct-but-toy now show the pattern in a small-but-plausible business scenario, so each file is something you can lift into real work:

Unit Now shows
structural/facade place_order() over inventory/payment/shipping/notification — incl. the rollback call sites forget (tested)
modern/dependency_injection invoice-reminder service with clock/source/mail seams; frozen-date tests, zero monkeypatching
structural/bridge alert + digest notifiers × email/Slack/SMS transports
creational/prototype report-job templates (partial + dataclasses.replace)
behavioral/mediator checkout form with cascading country→shipping→payment rules
creational/abstract_factory one sales report through HTML/Markdown document families

naive.py toys unchanged by design — the legible diff against them is the teaching device. READMEs aligned with the new domains.

Gates: ruff ✅ mypy --strict ✅ pytest 236 ✅ README table current ✅ all six demos run ✅

🤖 Generated with Claude Code

Rewrites pythonic.py (and tests) where the toy domain didn't answer
"what does this look like in a real system":

- facade: place_order() over inventory/payment/shipping/notification,
  with the payment-failure rollback tested
- dependency_injection: overdue-invoice reminders with clock, source,
  and mail seams — deterministic tests, no monkeypatching
- bridge: alert/digest notifiers bridged over email/Slack/SMS transports
- prototype: report-job templates via partial + dataclasses.replace
- mediator: checkout form with cascading country/shipping/payment rules
- abstract_factory: one report rendered through HTML/Markdown document
  families

naive.py toys kept as-is (the diff against them is the teaching device).
READMEs aligned. 236 tests; ruff/mypy --strict clean.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@SuperElectron
SuperElectron merged commit bcf2e2c into staging Aug 27, 2026
3 checks passed
SuperElectron added a commit that referenced this pull request Aug 27, 2026
* feat: v2 migration — adapter, bridge, composite as modules

Structural batch 1 of the patterns-as-modules refactor:
- adapter: pattern/ DelegatingAdapter; examples/payment_gateways (one
  checkout over two mismatched vendor SDKs, failure conventions unified)
- bridge: pattern/ Transport protocol + notifiers (PR #14 seed promoted);
  examples/notification_center (per-team transport routing)
- composite: pattern/ generic Composite/HasTotal with honest interfaces;
  examples/org_chart (headcount+cost rollups in one pass)
- three docs files per unit; legacy variant files removed

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

* feat: v2 migration — decorator, facade, flyweight, proxy as modules

Structural batch 2/2 of the patterns-as-modules refactor:
- decorator: pattern/ ships logged/timed/retry/rate_limited (ParamSpec-typed,
  effects injected); examples/resilient_client stacks them on a flaky client
  and pins the ordering policy
- facade: place_order checkout facade promoted to pattern/ (rollback intact,
  honest saga boundary); examples/order_checkout batch-processes orders
  through the one door
- flyweight: pattern/ ships InternPool with an immutability guard;
  examples/glyph_styles holds ~30k glyphs on 2 shared styles
- proxy: pattern/ ships stackable LazyProxy/ProtectionProxy/MeteringProxy;
  examples/db_gateway composes all three over one expensive connection
- each unit: docs/{fundamentals,implementation,examples}.md with the
  classic-form contrast and cited external usages; legacy variant files and
  tests removed

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

* feat: v2 modules — structural group (adapter, bridge, composite, decorator, facade, flyweight, proxy)

Assembles feat/v2-structural-1 + -2. Also: fleet example-imports-pattern
check upgraded to an AST import walk; legacy sandbox test moved onto the
synthetic legacy fixture.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

* fix: structural review findings — LazyProxy sentinel, recursive InternPool guard, fleet examples test

_MISSING sentinel caches falsy subjects; strict interning recurses into
containers; bridge 2x3 asserted + registry house rule; all legacy sandbox
tests on the synthetic fixture; parametrized run of every module unit's
examples; facade rollback releases on any charge failure.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
@SuperElectron
SuperElectron deleted the feat/richer-examples branch August 27, 2026 21:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant