refactor(topics): 멀티 에이전트용 지식 재편 — _Common(공통 기본기) + Domain_* 구조
에이전트 8종(대화형/프로그래머 C·S/디자이너/설계자/기획자/QA/PD/PM)에게 [공통 기본 능력 + 롤별 Specialty] 2층으로 지식을 주입하기 위한 재분류. 문서 내용·포맷은 무수정, 폴더 이동만 (6,372개 문서 수 보존 확인). - Topic_Programming → Domain_Programming (내부 구조 보존) - Topic_Graphic → Domain_Design - Topic_Business → Domain_Product - Topic_General → Domain_General - _Common 신설: Math(구 Topic_Math_Specialty), Reasoning(구 General/From_Thinking & Reasoning), Reasoning_Creativity(구 General/From_창의성), Communication(Poetic_Blog_Writing + From_writing) - 타 도메인의 From_* 폴더는 유지 (출처 표기일 뿐, 이미 도메인에 맞게 분류된 문서) - 빈 폴더 정리 (memory/procedures) - 에이전트→폴더 매핑은 workspace의 .astra/agent-knowledge-map.json (9개 에이전트) Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,185 @@
|
||||
---
|
||||
id: wiki-2026-0508-god-object-antipattern
|
||||
title: God Object Antipattern
|
||||
category: 10_Wiki/Topics
|
||||
status: verified
|
||||
canonical_id: self
|
||||
aliases: [God Class, Blob, Monster Class]
|
||||
duplicate_of: none
|
||||
source_trust_level: A
|
||||
confidence_score: 0.9
|
||||
verification_status: applied
|
||||
tags: [architecture, antipattern, oop, refactoring, code-smell]
|
||||
raw_sources: []
|
||||
last_reinforced: 2026-05-10
|
||||
github_commit: pending
|
||||
tech_stack:
|
||||
language: typescript
|
||||
framework: language-agnostic
|
||||
---
|
||||
|
||||
# God Object Antipattern
|
||||
|
||||
## 매 한 줄
|
||||
> **"매 single class/module 의 too many responsibilities 의 absorption 의 통한 maintainability 의 collapse"**. 매 Brown et al. "AntiPatterns" (1998) 의 catalog, 매 procedural code 의 OOP 로 의 lift-and-shift 의 결과 — 매 modern microservices 시대 의 "God Service" 로 의 mutation.
|
||||
|
||||
## 매 핵심
|
||||
|
||||
### 매 Symptoms
|
||||
- 1000+ LOC class, 50+ methods.
|
||||
- 매 unrelated domain 의 mix (User + Order + Payment + Logging).
|
||||
- 매 import 의 fan-in 의 high — 매 module 의 reference 의 most.
|
||||
- Test 의 setup 의 100+ lines mock.
|
||||
- Git log 의 churn 의 highest hot-spot.
|
||||
|
||||
### 매 Causes
|
||||
- SRP (Single Responsibility) 의 violation.
|
||||
- Premature centralization ("Manager", "Controller", "Helper" suffix).
|
||||
- Feature 의 incremental 의 add 의 always-cheapest-place 의 dump.
|
||||
- Refactoring fear (test 의 X, dependency 의 web).
|
||||
|
||||
### 매 응용 (detection)
|
||||
1. SonarQube "Brain Class" rule.
|
||||
2. Lizard / radon 의 cyclomatic + LOC metric.
|
||||
3. CodeScene hotspot map.
|
||||
|
||||
## 💻 패턴
|
||||
|
||||
### Smell — God Class
|
||||
```typescript
|
||||
// 🚨 God Object
|
||||
export class ApplicationManager {
|
||||
users: User[] = [];
|
||||
orders: Order[] = [];
|
||||
cart: Cart;
|
||||
paymentGateway: Stripe;
|
||||
logger: Logger;
|
||||
cache: Redis;
|
||||
// ... 47 more fields
|
||||
|
||||
registerUser(...) { /* 80 lines */ }
|
||||
authenticateUser(...) { /* 60 lines */ }
|
||||
createOrder(...) { /* 120 lines, calls payment, cache, log */ }
|
||||
refundOrder(...) { /* 90 lines */ }
|
||||
sendEmail(...) { /* 40 lines */ }
|
||||
generateReport(...) { /* 200 lines */ }
|
||||
// ... 50 more methods
|
||||
}
|
||||
```
|
||||
|
||||
### Refactor — Extract Class (SRP)
|
||||
```typescript
|
||||
export class UserService {
|
||||
constructor(private repo: UserRepository, private hasher: PasswordHasher) {}
|
||||
async register(input: RegisterInput) { /* ... */ }
|
||||
async authenticate(creds: Credentials) { /* ... */ }
|
||||
}
|
||||
|
||||
export class OrderService {
|
||||
constructor(
|
||||
private repo: OrderRepository,
|
||||
private payment: PaymentGateway,
|
||||
private events: EventBus,
|
||||
) {}
|
||||
async create(input: CreateOrderInput) { /* ... */ }
|
||||
async refund(orderId: string) { /* ... */ }
|
||||
}
|
||||
|
||||
export class ReportingService { /* ... */ }
|
||||
```
|
||||
|
||||
### Replace Conditional with Polymorphism
|
||||
```typescript
|
||||
// Before: god method 의 switch
|
||||
processPayment(method: string, amount: number) {
|
||||
if (method === 'card') { /* ... */ }
|
||||
else if (method === 'paypal') { /* ... */ }
|
||||
else if (method === 'crypto') { /* ... */ }
|
||||
}
|
||||
|
||||
// After: Strategy
|
||||
interface PaymentMethod { charge(amount: number): Promise<Receipt>; }
|
||||
class CardPayment implements PaymentMethod { /* ... */ }
|
||||
class PayPalPayment implements PaymentMethod { /* ... */ }
|
||||
class CryptoPayment implements PaymentMethod { /* ... */ }
|
||||
|
||||
class PaymentService {
|
||||
constructor(private methods: Map<string, PaymentMethod>) {}
|
||||
charge(method: string, amount: number) {
|
||||
return this.methods.get(method)!.charge(amount);
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### Extract Aggregate (DDD)
|
||||
```typescript
|
||||
// God 의 split → Aggregate Root + Value Objects
|
||||
export class Order {
|
||||
private constructor(
|
||||
public readonly id: OrderId,
|
||||
private items: LineItem[],
|
||||
private status: OrderStatus,
|
||||
) {}
|
||||
|
||||
static create(customerId: CustomerId, items: LineItem[]): Order { /* ... */ }
|
||||
addItem(item: LineItem) { /* invariant 의 enforce */ }
|
||||
confirm(): DomainEvent[] { /* ... */ }
|
||||
}
|
||||
```
|
||||
|
||||
### ESLint Rule (max-lines-per-function/class)
|
||||
```json
|
||||
{
|
||||
"rules": {
|
||||
"max-lines": ["error", { "max": 400, "skipBlankLines": true }],
|
||||
"max-lines-per-function": ["error", 60],
|
||||
"complexity": ["error", 10]
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### SonarQube Detection
|
||||
```properties
|
||||
sonar.cpd.exclusions=**/*.test.ts
|
||||
# Rule: java:S2972 (Inner classes should not have too many lines)
|
||||
# Rule: typescript:S138 (Functions should not have too many lines)
|
||||
# Rule: common:DuplicatedBlocks
|
||||
```
|
||||
|
||||
## 매 결정 기준
|
||||
| 상황 | Approach |
|
||||
|---|---|
|
||||
| Class > 500 LOC | Extract Class by responsibility |
|
||||
| Method > 60 LOC | Extract Method, Replace Temp with Query |
|
||||
| Long parameter list | Introduce Parameter Object |
|
||||
| Switch on type | Replace Conditional with Polymorphism |
|
||||
| Cross-domain mix | Extract Bounded Context (DDD) |
|
||||
|
||||
**기본값**: 매 SRP — 매 class 의 one reason to change.
|
||||
|
||||
## 🔗 Graph
|
||||
- 부모: [[Code Smells]]
|
||||
- 변형: [[Big-Ball-of-Mud]] · [[Distributed-Monolith]]
|
||||
- 응용: [[Refactoring_Best_Practices|Refactoring]] · [[SOLID]] · [[DDD]]
|
||||
- Adjacent: [[High-Cohesion-Low-Coupling]] · [[Single Responsibility Principle (SRP)|Single-Responsibility-Principle]] · [[Bounded Context]]
|
||||
|
||||
## 🤖 LLM 활용
|
||||
**언제**: god class 의 detect, extract-class 의 refactor 의 suggest, responsibility 의 cluster 의 propose.
|
||||
**언제 X**: 매 large refactor 의 final commit (test coverage 의 human verification 필수).
|
||||
|
||||
## ❌ 안티패턴
|
||||
- **Manager/Helper suffix**: 매 dumping ground 의 invitation.
|
||||
- **Static God**: `Utils` static class 의 grow → 매 testability 의 destroy.
|
||||
- **God Service**: microservice 시대 의 god — single service 의 매 domain 의 own.
|
||||
- **Refactor without tests**: 매 god 의 split 의 시 behavior 의 break 의 silent.
|
||||
- **Premature split**: 매 50 LOC class 의 over-decompose → 매 anemic + indirection 의 hell.
|
||||
|
||||
## 🧪 검증 / 중복
|
||||
- Verified (Brown et al. "AntiPatterns" 1998, Fowler "Refactoring" 2nd ed., SonarSource rules).
|
||||
- 신뢰도 A.
|
||||
|
||||
## 🕓 Changelog
|
||||
| 날짜 | 변경 |
|
||||
|---|---|
|
||||
| 2026-05-08 | Phase 1 |
|
||||
| 2026-05-10 | Manual cleanup — god object antipattern 의 full content |
|
||||
Reference in New Issue
Block a user