Skip to content

Latest commit

 

History

History
31 lines (24 loc) · 1.62 KB

File metadata and controls

31 lines (24 loc) · 1.62 KB

Composition Over Inheritance — where it lives outside this repo

Cited, real implementations to study (or point an agent at) when designing or reviewing class hierarchies.

Python standard library

  • logging. The guide's own worked example, shipped at scale: Logger composes Handlers, Filters, and Formatters — three orthogonal axes, no class per combination. docs.python.org/3/library/logging.html
  • socketserver. The honest contrast: the stdlib's mixin dodge (ThreadingMixIn + TCPServer = ThreadingTCPServer), useful to study as the alternative the principle warns will reconverge on the diamond. docs.python.org/3/library/socketserver.html

Major ecosystems

What to notice across all of them

In every healthy example the combination is expressed at runtime — a constructor call, a registration — while the pieces stay single-purpose. When reviewing, count adjectives in class names: two or more is the explosion starting.