f8b21af4be
10_Wiki/Topics 대규모 정리: - 오류 캡처/미완성 stub 문서 227개 제거 - 교차폴더 중복 43클러스터 병합 (63파일 → redirect) - 링크명 정규화: 깨진 링크 수정·redirect 직결·개념 매핑 ~2,400건 - 카테고리 MOC 6개 신규 생성 - Graph 섹션 미해결 related-keyword 링크 10,058건 제거 Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
6.3 KiB
6.3 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-object-oriented-programming | Object-Oriented Programming (OOP) | 10_Wiki/Topics | verified | self |
|
none | A | 0.95 | applied |
|
2026-05-10 | pending |
|
Object-Oriented Programming (OOP)
매 한 줄
"매 data + behavior를 object로 묶고, polymorphism으로 동작을 추상화하는 패러다임.". Simula 67 (1967) → Smalltalk (1972) → C++ (1985) → Java (1995) → 매 mainstream. 2026 현재는 OO + FP hybrid가 dominant — Java records, Kotlin data class, TypeScript readonly class, Rust trait이 그 증거.
매 핵심
매 4 pillar
- Encapsulation: 매 internal state hide, expose behavior —
privatefield +publicmethod. - Inheritance: 매 reuse + specialize — 단 favor composition over inheritance (GoF).
- Polymorphism: 매 same interface, different impl — virtual dispatch · duck typing.
- Abstraction: 매 essential 만 expose — interface · abstract class.
매 SOLID (Robert C. Martin)
- Single Responsibility — 매 class one reason to change.
- Open/Closed — 매 extend without modify.
- Liskov Substitution — 매 subtype substitutable.
- Interface Segregation — 매 small focused interfaces.
- Dependency Inversion — 매 depend on abstraction.
매 응용
- Domain-Driven Design — Entity, Value Object, Aggregate.
- GUI framework — Component hierarchy (React class component, Qt widget).
- Game engine — Entity-Component-System (modern hybrid).
💻 패턴
Encapsulation — invariant 보장
public final class Money {
private final BigDecimal amount;
private final Currency currency;
public Money(BigDecimal a, Currency c) {
if (a.signum() < 0) throw new IllegalArgumentException("negative");
this.amount = a; this.currency = c;
}
public Money add(Money other) {
if (!currency.equals(other.currency))
throw new IllegalStateException("currency mismatch");
return new Money(amount.add(other.amount), currency);
}
}
Polymorphism — strategy
interface Shipping {
calculate(weight: number): number;
}
class StandardShipping implements Shipping {
calculate(w: number) { return w * 5; }
}
class ExpressShipping implements Shipping {
calculate(w: number) { return w * 12 + 10; }
}
function totalCost(items: Item[], shipping: Shipping): number {
const w = items.reduce((s, i) => s + i.weight, 0);
return items.reduce((s, i) => s + i.price, 0) + shipping.calculate(w);
}
Composition over inheritance
// BAD: deep hierarchy
class Animal {}
class Dog extends Animal {}
class FlyingDog extends Dog {} // ???
// GOOD: composition
class Animal {
constructor(
private mover: Movement,
private noise: NoiseMaker,
) {}
move() { return this.mover.move(); }
speak() { return this.noise.sound(); }
}
const dog = new Animal(new Walking(), new Bark());
const bird = new Animal(new Flying(), new Chirp());
Abstract class + template method
public abstract class HttpHandler {
public final Response handle(Request req) {
if (!authenticate(req)) return Response.unauthorized();
var data = process(req);
return render(data);
}
protected abstract boolean authenticate(Request req);
protected abstract Object process(Request req);
protected Response render(Object data) {
return Response.ok().json(data);
}
}
Modern hybrid — record (Java 21) / data class
public record User(UserId id, Email email, String name) {
public User { // compact constructor
Objects.requireNonNull(email);
if (name.isBlank()) throw new IllegalArgumentException();
}
public User withName(String n) { return new User(id, email, n); }
}
Trait-based OOP (Rust)
trait Drawable {
fn draw(&self, canvas: &mut Canvas);
fn bounds(&self) -> Rect;
}
struct Circle { center: Point, r: f32 }
impl Drawable for Circle {
fn draw(&self, c: &mut Canvas) { c.circle(self.center, self.r); }
fn bounds(&self) -> Rect { Rect::around(self.center, self.r) }
}
fn render_all(shapes: &[Box<dyn Drawable>], canvas: &mut Canvas) {
for s in shapes { s.draw(canvas); }
}
매 결정 기준
| 상황 | Approach |
|---|---|
| Domain with complex invariants | OOP + DDD entities/VO |
| Pure data transformation | FP (immutable + pure functions) |
| Plug-in / extensibility | Interface + DI |
| State machine | OOP class with explicit states |
| Hot loop, ECS scale | Data-Oriented (avoid virtual dispatch) |
기본값: hybrid OOP+FP — value objects immutable, services with interfaces, pure functions for transforms.
🔗 Graph
- 변형: Functional_Programming · Procedural-Architecture-Systems · ECS
- 응용: SOLID Principles · Polymorphism (다형성) · Object Seam (객체 접점) · Bounded_Context
- Adjacent: High-Cohesion-Low-Coupling · Dependency_Inversion_Principle · Hexagonal_Architecture_Ports_and_Adapters
🤖 LLM 활용
언제: business domain modeling, framework/library design, GUI hierarchy, plug-in architecture. 언제 X: hot numerical loop (DOD better), pure transform pipeline (FP cleaner), 1-file script.
❌ 안티패턴
- God Object: 매 모든 책임 한 class — SRP 위반.
- Anemic Domain Model: data only, behavior in service — OOP 무력화.
- Deep inheritance (4+ levels): 매 fragile base class.
- Premature interface: 매 single impl을 interface로 — YAGNI.
- Setter everywhere: 매 invariant 깨짐 — immutable + factory.
🧪 검증 / 중복
- Verified (GoF Design Patterns 1994, Martin Clean Code 2008, Evans DDD 2003, Java/Kotlin/Rust 2026 docs).
- 신뢰도 A.
- Duplicates:
객체_지향_프로그래밍(OOP).md,객체_지향_프로그래밍_Object-Oriented_Programming,_OOP.mdshould redirect here.
🕓 Changelog
| 날짜 | 변경 |
|---|---|
| 2026-05-08 | Phase 1 |
| 2026-05-10 | Manual cleanup — canonical OOP doc (4 pillars + SOLID + modern hybrid) |