Files
2nd/10_Wiki/Topics/Architecture/하향식_탐색_Top-Down_Approach.md
T
koriweb d8a80f6272 chore(wiki): dangling 링크 canonical 정규화 (768파일/1200건)
이름만 다른(표기 변형) [[위키링크]]를 대상 문서의 canonical 제목으로 치환해
끊겼던 1,200개 링크를 연결. 제목/파일명 정규화 일치만 적용하고 별칭 매칭은
과병합 위험으로 제외(애매성 가드). 원본은 _link_reconcile_backup/ 에 백업.
도구: Datacollect/scripts/link_reconcile_apply.mjs

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-08 12:24:15 +09:00

5.4 KiB

id, title, category, status, canonical_id, aliases, duplicate_of, source_trust_level, confidence_score, verification_status, tags, raw_sources, last_reinforced, github_commit, tech_stack
id title category status canonical_id aliases duplicate_of source_trust_level confidence_score verification_status tags raw_sources last_reinforced github_commit tech_stack
wiki-2026-0508-하향식-탐색-top-down-approach 하향식 탐색 Top-Down Approach 10_Wiki/Topics verified self
Top-Down Design
Stepwise Refinement
하향식 설계
none A 0.9 applied
architecture
design-method
decomposition
2026-05-10 pending
language framework
language-agnostic design-method

하향식 탐색 (Top-Down Approach)

매 한 줄

"매 큰 그림 → 매 세부". 매 system 의 high-level abstraction 부터 시작 → 매 단계마다 decomposition. 매 1970s Niklaus Wirth 의 stepwise refinement 가 origin — 매 modern 2026 microservice / DDD 의 strategic design 까지 매 살아있는 design heuristic.

매 핵심

매 핵심 idea

  • 매 추상 → 매 구체: System 전체 → subsystems → modules → functions → lines.
  • 매 deferred decision: Lower-level detail 의 결정 의 미루기 — 매 abstraction barrier.
  • 매 wishful thinking: 매 "이 helper 가 있다 가정" → 매 나중에 implement.

매 vs Bottom-Up

  • Top-Down: 매 unknown / new system 의 design 적합. 매 risk: leaf-level 에서 매 mismatch 발견.
  • Bottom-Up: 매 reusable primitive 부터. 매 known domain (e.g. data pipeline) 적합.
  • 매 실전: 매 hybrid (meet-in-middle) 의 default.

매 응용

  1. DDD strategic design — bounded context → context map → aggregate.
  2. Microservice decomposition — capability mapping → service boundary.
  3. Functional decomposition — main() → step functions → primitives.

💻 패턴

Stepwise refinement (pseudocode → real)

# Level 0: intent
def process_orders():
    """Process today's orders end-to-end."""

# Level 1: high-level steps
def process_orders():
    orders = fetch_pending_orders()
    validated = [o for o in orders if validate(o)]
    results = [charge_and_ship(o) for o in validated]
    notify_customers(results)

# Level 2: implement leaves (deferred until now)
def fetch_pending_orders() -> list[Order]:
    return db.query(Order).filter(Order.status == "pending").all()

Wishful thinking — assume helpers exist

def render_dashboard(user_id: str) -> HTML:
    user = fetch_user(user_id)              # assume
    metrics = compute_metrics(user)         # assume
    chart = build_chart(metrics)            # assume
    return layout(header(user), chart)      # assume
# 매 implement leaves 의 last.

DDD top-down decomposition

Bounded Context: Order Management
  ├─ Aggregate: Order
  │   ├─ Entity: OrderLine
  │   └─ Value Object: Money, Address
  ├─ Aggregate: Cart
  └─ Domain Service: Pricing

Microservice capability decomposition

# top-down: business capability → service
Capability: Checkout
  Sub-capability: Cart Management   → cart-service
  Sub-capability: Payment           → payment-service
  Sub-capability: Order Persistence → order-service
  Sub-capability: Notification      → notification-service

Test-first top-down (London-school TDD)

def test_charge_order_calls_gateway(mocker):
    gateway = mocker.Mock()
    repo = mocker.Mock()
    svc = OrderService(gateway, repo)         # 매 collaborator 추측
    svc.charge(Order(id=1, total=100))
    gateway.charge.assert_called_once_with(100)
# 매 mock 의 design 의 driver — 매 collaborator interface 의 top-down emerge.

Recursive descent parser (top-down classic)

def parse_expr(tokens):
    left = parse_term(tokens)
    while tokens.peek() in ("+", "-"):
        op = tokens.next()
        right = parse_term(tokens)
        left = BinOp(op, left, right)
    return left

def parse_term(tokens):
    left = parse_factor(tokens)
    # ...

매 결정 기준

상황 Approach
Greenfield, unknown domain Top-Down (explore via decomposition)
Known primitives, integration heavy Bottom-Up
Library 의 design Bottom-Up (primitive first)
Application / product 의 design Top-Down → Hybrid
Refactor existing code Inside-Out (seam first)

기본값: Top-Down 으로 strategy → bottom-up primitive 의 meet-in-middle.

🔗 Graph

🤖 LLM 활용

언제: 매 새로운 system 의 design 의 시작, 매 unknown domain 의 explore, 매 architectural conversation 의 frame. 언제 X: 매 well-known primitive 의 mechanical assembly, 매 retrofit / legacy refactor (seam-first 가 더 안전).

안티패턴

  • Pseudocode 가 implementation 화: 매 leaf 의 implement 안 함. 매 wishful 의 영원히 wish.
  • Premature decomposition: 매 너무 일찍 fix layer boundary → 매 나중에 leaky.
  • No bottom check: 매 leaf primitive 가 매 expressible 인지 verify 안 함 → 매 mismatch.

🧪 검증 / 중복

  • Verified (Wirth 1971 "Program Development by Stepwise Refinement"; Evans DDD 2003).
  • 신뢰도 A.

🕓 Changelog

날짜 변경
2026-05-08 Phase 1
2026-05-10 Manual cleanup — top-down 의 stepwise refinement / wishful thinking / DDD-microservice 의 application