"매 small piece 의 arrange 의 emergent capability 의 만든다". 매 Design Patterns (GoF, 1994) 의 "favor composition over inheritance" 의 most-cited principle. 매 2026 의 React Server Components, Unix pipes, fp-ts pipe, kubernetes operator composition 의 same idea 의 different incarnation.
매 핵심
매 composition modes
Function composition: f ∘ g — output 의 input 의 chain.
Object composition: 매 has-a > is-a — delegation, mixin, trait.
Component composition: 매 React/Vue children, slot. 매 layout 의 declarative.
Process composition: 매 Unix pipes, k8s sidecar, DAG (Airflow).
Type composition: 매 union, intersection, generics.
매 arrangement axes
Horizontal: 매 sibling 의 parallel — fan-out / fan-in.
Vertical: 매 layer / pipeline — sequential.
Tree: 매 hierarchy — 매 component tree / DOM.
Graph: 매 arbitrary edges — 매 dataflow / DAG.
매 응용
UI — 매 component slot, render prop, children-as-function.
Data pipeline — 매 dbt model graph, Airflow DAG.
Function-level — 매 pipe / compose / Result.flatMap.
Service mesh — 매 sidecar composition (Envoy + app).
💻 패턴
Function composition (TypeScript / fp-ts)
import{pipe,flow}from'fp-ts/function';consttrim=(s: string)=>s.trim();constlower=(s: string)=>s.toLowerCase();constslug=(s: string)=>s.replace(/\s+/g,'-');constslugify=flow(trim,lower,slug);// point-free
constout=pipe(' Hello World ',trim,lower,slug);// value-first
console.log(slugify(' Hello World '));// "hello-world"
Composition over inheritance (Go — embedding)
typeLoggerstruct{prefixstring}func(lLogger)Log(msgstring){fmt.Println(l.prefix,msg)}typeCounterstruct{nint}func(c*Counter)Inc(){c.n++}// HTTP server composes both — no inheritancetypeServerstruct{Logger// embedded → Server.Log() works*Counter// embedded pointeraddrstring}s:=&Server{Logger:Logger{"[srv]"},Counter:&Counter{},addr:":8080"}s.Log("starting");s.Inc()
React component composition
// "Slot" composition — children as primary API
functionCard({header,footer,children}:{header?: ReactNode;footer?: ReactNode;children: ReactNode;}){return(<divclassName="card">{header&&<header>{header}</header>}<main>{children}</main>{footer&&<footer>{footer}</footer>}</div>);}<Cardheader={<h2>Order#1234</h2>}footer={<button>Cancel</button>}><OrderDetailsid="1234"/></Card>
fromdagsterimportasset@assetdefraw_orders():returnload_csv("orders.csv")@assetdefcleaned_orders(raw_orders):returnraw_orders.dropna()@assetdefdaily_revenue(cleaned_orders):returncleaned_orders.groupby("day")["total"].sum()# Dagster builds DAG from inputs → outputs automatically
언제: 매 inheritance hierarchy → composition 의 refactor suggestion, 매 pipeline의 DAG 의 visualize.
언제 X: 매 deep domain modeling — 매 human 의 boundary judgment 의 필수.
❌ 안티패턴
Inheritance for code reuse: 매 fragile base class — 매 composition 의 사용.
Composition explosion: 매 100-deep wrapper — 매 readability 의 X. 매 refactor.
God component: 매 50-prop slot — 매 split.
Implicit composition order: 매 HOC stacking 의 order-dependent — 매 explicit naming.
🧪 검증 / 중복
Verified (Gamma et al., Design Patterns; React docs — composition vs inheritance; Wadler — Theorems for Free).