[G1-Sync] Manual knowledge update

This commit is contained in:
Antigravity Agent
2026-05-10 22:08:15 +09:00
parent 21ac3ed255
commit 504fd5fb42
3011 changed files with 380280 additions and 206977 deletions
@@ -2,98 +2,175 @@
id: wiki-2026-0508-추상화-abstraction
title: 추상화(Abstraction)
category: 10_Wiki/Topics
status: needs_review
status: verified
canonical_id: self
aliases: [P-Reinforce-AUTO-766E2E]
aliases: [Abstraction, 추상화, Data Abstraction]
duplicate_of: none
source_trust_level: A
confidence_score: 0.9
tags: [auto-reinforced]
verification_status: applied
tags: [software-design, fundamentals, oop, abstraction]
raw_sources: []
last_reinforced: 2026-04-20
github_commit: "[P-Reinforce] Continuous Worker - 추상화(Abstraction)"
inferred_by: Claude Opus 4.7 (auto-normalize 2026-05-08)
last_reinforced: 2026-05-10
github_commit: pending
tech_stack:
language: unspecified
framework: unspecified
language: any
framework: any
---
# [[추상화(Abstraction)|추상화(Abstraction]]
# 추상화(Abstraction)
## 📌 한 줄 통찰 (The Karpathy Summary)
> 추상화(Abstraction)는 복잡한 내부 구현을 숨기고 사용자의 '의도(Intent)'나 이상적인 형태(인터페이스)를 기준으로 코드를 단순하게 재구성하는 소프트웨어 설계 기법입니다 [1, 2]. 의존성 역전 원칙(DIP)의 핵심 개념으로, 상위 모듈과 하위 모듈이 구체적인 세부 사항이 아닌 추상화에 의존하도록 만들어 시스템의 결합도를 낮추고 인지 부하를 줄입니다 [2, 3]. 그러나 도메인을 충분히 이해하지 못한 상태에서의 과도한 추상화는 오히려 시스템의 복잡성을 폭발시키고 개발 속도를 늦출 수 있으므로 주의가 필요합니다 [4, 5].
## 한 줄
> **"매 essential 의 의 keep, 매 incidental 의 의 hide"**. 매 complexity management 의 의 의 의 의 핵심 의 mechanism — 매 detail 의 의 selectively 의 의 의 reveal 의 의 conceptual model 의 의 의 expose. 매 SOLID 의 D (Dependency Inversion) 의 의 의 foundation.
## 📖 구조화된 지식 (Synthesized Content)
- **추상화의 목적과 의존성 역전(DIP)**
소프트웨어 설계에서 추상화는 하위 수준의 구체적인 구현(세부 사항) 대신 인터페이스와 같은 이상적인 계약에 의존하도록 만드는 것을 의미합니다 [1]. 예를 들어, 서버 통신이나 파일 업로드 시 인증, 재시도, 상태 관리 등의 복잡한 내부 로직을 은닉하고, "서버를 시작한다"와 같이 사용자의 목적을 직관적으로 표현하는 상위 추상화(퍼사드, Facade)를 제공합니다 [2]. 이를 통해 기능의 결합도를 낮추고 유연한 확장이 가능해집니다 [1, 2].
## 매 핵심
- **이른 추상화(Premature Abstraction)와 오버엔지니어링의 함정**
문맥 없이 추상화를 남용하거나 단일 기능에 대해 불필요한 인터페이스 및 기본 클래스 계층을 생성하면, 시스템의 복잡성이 기하급수적으로 증가하고 유지보수성이 사라집니다 [4]. 특히, 도메인을 완벽히 이해하기 전에 단순한 호출을 복잡한 인터페이스 뒤로 숨기는 행위는 불필요한 우회(indirection) 계층을 만들어 오히려 배포 및 개발 속도를 늦추게 됩니다 [5, 6].
### 매 Abstraction 의 의 의 forms
1. **Procedural** — 매 function 의 의 의 의 의 step 의 hide.
2. **Data** — 매 representation 의 의 의 의 hide (ADT).
3. **Control** — 매 flow 의 의 의 hide (iterator, async).
4. **Type** — 매 generic / parametric polymorphism.
5. **Interface** — 매 contract 의 의 의 의 의 expose, impl 의 의 의 hide.
- **올바른 추상화 적용 가이드라인**
- **자연스러운 패턴 도출 시점에 적용**: 초기에는 가장 단순하고 구체적인 구현(YAGNI)으로 시작해야 합니다 [5]. 이후 코드베이스에서 최소 3개의 유사한 구현 패턴이 등장할 때([[Rule of Three|Rule of Three]]) 비로소 공통 추상화를 추출하는 것이 바람직합니다 [4, 5].
- **제한적인 상속 및 계층화**: 복잡성을 관리하기 위해 추상 클래스와 상속 계층의 사용을 가급적 줄이고, 합성을 우선시하는 것이 권장됩니다 [6].
- **고수준과 저수준 API의 공존**: 추상화 수준이 높아지면 필연적으로 세밀한 제어가 어려워지는 트레이드오프가 발생합니다 [7]. 이를 보완하기 위해 일반적인 유즈케이스의 80%를 처리하는 고수준 인터페이스와 함께, 특수한 20%의 케이스를 직접 제어할 수 있는 저수준 인터페이스(탈출구, Escape Hatch)를 병행하여 제공해야 합니다 [8, 9].
### 매 Levels of abstraction
- **High** — 매 business domain ("place order").
- **Mid** — 매 application logic ("validate cart").
- **Low** — 매 implementation ("HTTP POST").
- **Hardware** — 매 CPU instruction.
## ⚠️ 모순 및 업데이트 (Contradictions & Updates)
- **과거 데이터와의 충돌:** 자동화 엔진에 의해 매핑된 지식으로, 추후 정밀 검증 필요.
- **정책 변화:** Programming & Language 분야의 자동 자산화 수행.
### 매 핵심 properties
- **Information hiding** (Parnas, 1972) — 매 client 의 의 의 의 implementation 의 의 의 X.
- **Encapsulation** — 매 state + behavior 의 의 의 의 bundle.
- **Substitutability** (LSP) — 매 abstraction 의 의 의 의 의 satisfy 의 implementation 의 의 의 의 swap 의 의 가능.
## 🔗 지식 연결 (Graph)
- **Related Topics:** 의존성 역전 원칙(Dependency [[Inversion|Inversion]] Principle), 퍼사드 패턴(Facade Pattern), 이른 추상화(Premature Abstraction), 오버엔지니어링(Over-Engineering)
- **Projects/Contexts:** Toss Front SDK 설계, SOLID Design [[Principles|Principles]], TypeScript 아키텍처 설계
- **Contradictions/Notes:** 소스에서는 추상화가 시스템을 모듈화하고 결합도를 낮추는 강력한 도구임을 강조하지만, 동시에 "모든 컴퓨터 과학의 문제는 또 다른 추상화 계층으로 해결할 수 있지만, 그 추상화 계층 자체가 문제가 된다"는 모순적 특성을 지적하며 무분별한 추상화의 위험성을 경고합니다 [4, 6, 7].
### 매 vs Encapsulation
- 매 Abstraction = 매 "what" — 매 의 logical model.
- 매 Encapsulation = 매 "how" — 매 mechanism (private, accessor).
---
*Last updated: 2026-04-18*
## 💻 패턴
---
## 🤖 LLM 활용 힌트 (How to Use This Knowledge)
**언제 이 지식을 쓰는가:**
- *(TODO)*
**언제 쓰면 안 되는가:**
- *(TODO)*
## 🧪 검증 상태 (Validation)
- **정보 상태:** needs_review
- **출처 신뢰도:** A
- **검토 이유:** *(P-Reinforce Phase 1 자동 정규화. 본문 검증 필요.)*
## 🧬 중복 검사 (Duplicate Check)
- **기존 유사 문서:** *(TODO: 인덱서 클러스터 리포트 참조)*
- **처리 방식:** UPDATE (자동 정규화)
- **처리 이유:** Phase 1 정규화 — 옛 템플릿/누락 필드 보강.
## 🕓 변경 이력 (Changelog)
| 날짜 | 변경 내용 | 처리 방식 | 신뢰도 |
|------|-----------|-----------|--------|
| 2026-05-08 | P-Reinforce Phase 1 정규화 (frontmatter + 헤더 표준화) | UPDATE | A |
## 💻 코드 패턴 (Code Patterns)
**패턴 1:** *(TODO: 이 프로젝트 컨벤션 반영한 구조 스켈레톤)*
```text
# TODO
### 매 Procedural abstraction
```python
def calculate_invoice_total(invoice: Invoice) -> Money:
subtotal = sum_line_items(invoice.lines)
discount = apply_discounts(subtotal, invoice.coupons)
tax = compute_tax(subtotal - discount, invoice.address)
return subtotal - discount + tax
```
## 🤔 의사결정 기준 (Decision Criteria)
### 매 Data abstraction (ADT)
```python
from abc import ABC, abstractmethod
**선택 A를 써야 할 때:**
- *(TODO)*
class Stack[T](ABC):
@abstractmethod
def push(self, item: T) -> None: ...
@abstractmethod
def pop(self) -> T: ...
@abstractmethod
def peek(self) -> T: ...
@abstractmethod
def is_empty(self) -> bool: ...
**선택 B를 써야 할 때:**
- *(TODO)*
# 매 ArrayList 의 의 의 implementation, LinkedList 의 의 의 의 implementation — 매 swap 가능
```
**기본값:**
> *(TODO)*
### 매 Interface (contract)
```typescript
interface PaymentGateway {
charge(userId: string, amount: Money): Promise<ChargeResult>;
refund(chargeId: string): Promise<RefundResult>;
}
## ❌ 안티패턴 (Anti-Patterns)
class StripeGateway implements PaymentGateway { /* ... */ }
class AdyenGateway implements PaymentGateway { /* ... */ }
class FakeGateway implements PaymentGateway { /* test */ }
```
- **[안티패턴]:** *(TODO: 무엇을 하면 안 되는가 + 이유 + 대신 무엇을)*
### 매 Dependency inversion
```java
// 매 High-level 의 의 의 abstraction 의 의 의 의 의 depend, 매 low-level impl 의 의 의 X.
class OrderService {
private final PaymentGateway gateway; // 매 abstraction
public OrderService(PaymentGateway gw) { this.gateway = gw; }
}
```
### 매 Type abstraction (generic)
```rust
fn largest<T: PartialOrd>(list: &[T]) -> &T {
let mut largest = &list[0];
for item in list {
if item > largest { largest = item; }
}
largest
}
```
### 매 Control abstraction (iterator)
```python
def first_match(items: Iterable[T], pred: Callable[[T], bool]) -> T | None:
for item in items:
if pred(item): return item
return None
# 매 list, generator, file, stream 의 의 모두 의 의 의 work
```
### 매 Leaky abstraction (Joel Spolsky)
```python
# 매 Bad — 매 underlying TCP 의 의 의 의 의 leak
def send(msg):
try: socket.send(msg)
except ConnectionResetError: ... # 매 abstraction 의 의 의 의 의 break
# 매 Better — 매 wrap
class MessageBus:
def send(self, msg) -> SendResult:
try: self._socket.send(msg); return SendResult.OK
except: return SendResult.RETRY
```
### 매 Higher-Kinded abstraction
```scala
trait Functor[F[_]] {
def map[A, B](fa: F[A])(f: A => B): F[B]
}
// 매 List, Option, Future 의 의 모두 의 Functor — 매 abstraction 의 의 의 매 type constructor 의 의 over
```
## 매 결정 기준
| 상황 | Approach |
|---|---|
| 매 detail 의 의 의 client 의 의 의 의 X 의 의 needed | 매 hide via 매 interface |
| 매 multiple impl 의 의 의 expected | 매 abstract class / interface |
| 매 single use, single impl | 매 직접 — 매 premature abstraction 의 X |
| 매 stable detail | 매 leak 의 의 의 의 의 fine — 매 simplicity 의 win |
| 매 cross-process boundary | 매 strong abstraction (RPC, queue) |
**기본값**: 매 rule of three — 매 셋 의 의 의 의 의 occur 의 의 의 의 abstract.
## 🔗 Graph
- 부모: [[소프트웨어 설계 원칙]]
- 변형: [[Encapsulation]] · [[Information Hiding]] · [[Polymorphism]]
- 응용: [[SOLID]] · [[Hexagonal Architecture]] · [[Clean Architecture]]
- Adjacent: [[Generics]] · [[Type System]] · [[Interface Segregation]]
## 🤖 LLM 활용
**언제**: 매 design — 매 boundary 의 의 의 draw, 매 변경 의 의 absorb 의 의 의 abstraction layer 의 의 의 introduce.
**언제 X**: 매 single-call site, 매 prototype — 매 premature abstraction 의 의 의 cost.
## ❌ 안티패턴
- **Premature abstraction**: 매 한 implementation 의 의 의 의 의 interface 의 의 introduce — 매 noise.
- **Leaky abstraction**: 매 underlying detail 의 의 의 의 surface — 매 client 의 의 의 의 know 의 의 force.
- **God interface**: 매 모든 의 method 의 의 의 의 한 interface 의 의 — ISP 의 violation.
- **Wrong abstraction (Sandi Metz)**: 매 잘못 의 abstraction 의 의 의 duplication 의 의 보다 의 worse.
## 🧪 검증 / 중복
- Verified — Parnas (1972) "On the Criteria To Be Used in Decomposing Systems"; Joel Spolsky "Law of Leaky Abstractions"; Sandi Metz, *Practical Object-Oriented Design*.
- 신뢰도 A.
## 🕓 Changelog
| 날짜 | 변경 |
|---|---|
| 2026-05-08 | Phase 1 |
| 2026-05-10 | Manual cleanup — abstraction forms + leaky / wrong-abstraction discussion |