--- id: wiki-2026-0508-arrangement-and-composition title: Arrangement and Composition category: 10_Wiki/Topics status: verified canonical_id: self aliases: [composition-over-inheritance, function-composition, ui-composition] duplicate_of: none source_trust_level: A confidence_score: 0.9 verification_status: applied tags: [composition, design, architecture, functional] raw_sources: [] last_reinforced: 2026-05-10 github_commit: pending tech_stack: language: typescript framework: react --- # Arrangement and Composition ## 매 한 줄 > **"매 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. ### 매 응용 1. UI — 매 component slot, render prop, children-as-function. 2. Data pipeline — 매 dbt model graph, Airflow DAG. 3. Function-level — 매 pipe / compose / Result.flatMap. 4. Service mesh — 매 sidecar composition (Envoy + app). ## 💻 패턴 ### Function composition (TypeScript / fp-ts) ```ts import { pipe, flow } from 'fp-ts/function'; const trim = (s: string) => s.trim(); const lower = (s: string) => s.toLowerCase(); const slug = (s: string) => s.replace(/\s+/g, '-'); const slugify = flow(trim, lower, slug); // point-free const out = pipe(' Hello World ', trim, lower, slug); // value-first console.log(slugify(' Hello World ')); // "hello-world" ``` ### Composition over inheritance (Go — embedding) ```go type Logger struct{ prefix string } func (l Logger) Log(msg string) { fmt.Println(l.prefix, msg) } type Counter struct{ n int } func (c *Counter) Inc() { c.n++ } // HTTP server composes both — no inheritance type Server struct { Logger // embedded → Server.Log() works *Counter // embedded pointer addr string } s := &Server{Logger: Logger{"[srv]"}, Counter: &Counter{}, addr: ":8080"} s.Log("starting"); s.Inc() ``` ### React component composition ```tsx // "Slot" composition — children as primary API function Card({ header, footer, children }: { header?: ReactNode; footer?: ReactNode; children: ReactNode; }) { return (
(C: ComponentType
) =>
(props: P) => useUser() ?
(C: ComponentType
, name: string) =>
(props: P) => { console.log(name, props); return