---
id: wiki-2026-0508-하향식-탐색-top-down-approach
title: 하향식 탐색 Top-Down Approach
category: 10_Wiki/Topics
status: verified
canonical_id: self
aliases: [Top-Down Design, Stepwise Refinement, 하향식 설계]
duplicate_of: none
source_trust_level: A
confidence_score: 0.9
verification_status: applied
tags: [architecture, design-method, decomposition]
raw_sources: []
last_reinforced: 2026-05-10
github_commit: pending
tech_stack:
  language: language-agnostic
  framework: 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)
```python
# 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
```python
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
```yaml
# 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)
```python
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)
```python
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
- 부모: [[아키텍처 패턴 지식]] · [[객체 지향 소프트웨어 아키텍처 설계]]
- 변형: [[Bottom-Up Approach]]
- 응용: [[DDD]] · [[Hexagonal_Architecture]] · [[Refactoring Techniques (리팩토링 기법)]]
- Adjacent: [[추상화(Abstraction)]] · [[High-Cohesion-Low-Coupling]]

## 🤖 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 |
