c24165b8bc
에이전트 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>
6.1 KiB
6.1 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-sprout-wrap-techniques-스프라우트-랩-기 | Sprout & Wrap Techniques (스프라우트 & 랩 기법) | 10_Wiki/Topics | verified | self |
|
none | A | 0.9 | applied |
|
2026-05-10 | pending |
|
Sprout & Wrap Techniques (스프라우트 & 랩 기법)
매 한 줄
"매 legacy code 의 직접 수정 X — 매 sprout 의 옆에 새 method/class 의 추가, 매 wrap 의 기존 caller 의 둘러쌈". Michael Feathers, Working Effectively with Legacy Code (2004) 의 4 paired 기법: Sprout Method, Sprout Class, Wrap Method, Wrap Class.
매 핵심
매 4 techniques
- Sprout Method: 매 새 method 의 옆에 grow, 매 caller 의 1줄 add.
- Sprout Class: 매 새 class 의 grow, 매 caller 의 instantiate + delegate.
- Wrap Method: 매 기존 method rename → 매 same name 의 new method 의 둘러쌈 (before/after logic).
- Wrap Class: 매 decorator/proxy 의 wrap (cross-cutting: logging, auth).
매 Sprout vs Wrap
- Sprout: 매 add new logic to existing operation.
- Wrap: 매 add cross-cutting (before/after) to existing operation 의 callers.
매 응용
- Add validation before legacy save.
- Add audit logging across all calls.
- Add caching layer transparently.
- Add feature flag toggle.
💻 패턴
Sprout Method
public void process(Order o) {
// legacy untouched
repo.save(o);
notifyCustomer(o); // sprouted
}
void notifyCustomer(Order o) { // tested
email.send(o.customer(), template(o));
}
Sprout Class — when sprout method 의 not enough
// Original legacy class — touch minimally
public class OrderProcessor {
public void process(Order o) {
repo.save(o);
new OrderNotifier(email, sms).notifyAll(o); // sprouted class
}
}
// New, fully tested
public class OrderNotifier {
private final EmailService email;
private final SmsService sms;
public OrderNotifier(EmailService e, SmsService s) { this.email = e; this.sms = s; }
public void notifyAll(Order o) {
email.send(o.customer().email(), "thanks");
if (o.customer().smsOptIn()) sms.send(o.customer().phone(), "order placed");
}
}
Wrap Method — rename + intercept
public class Pay {
// Step 1: rename original to *Internal
private void payInternal(Order o) {
gateway.charge(o.amount());
}
// Step 2: new method with same original name
public void pay(Order o) {
audit.log("pay.start", o.id()); // before
payInternal(o); // delegate
audit.log("pay.end", o.id()); // after
}
}
Wrap Class — Decorator
public interface PaymentGateway { void charge(long amount); }
public class StripeGateway implements PaymentGateway { /* legacy untouched */ }
public class LoggingGateway implements PaymentGateway {
private final PaymentGateway inner;
private final Logger log;
public LoggingGateway(PaymentGateway inner, Logger log) {
this.inner = inner; this.log = log;
}
@Override public void charge(long amount) {
log.info("charge.start amount={}", amount);
try { inner.charge(amount); }
finally { log.info("charge.end"); }
}
}
// Wire-up: clients see PaymentGateway, get wrapped version
PaymentGateway gw = new LoggingGateway(new StripeGateway(), log);
Wrap Class for caching
public class CachingRepo implements OrderRepository {
private final OrderRepository inner;
private final Map<Long, Order> cache = new ConcurrentHashMap<>();
public CachingRepo(OrderRepository inner) { this.inner = inner; }
public Order findById(long id) {
return cache.computeIfAbsent(id, inner::findById);
}
public Order save(Order o) {
var saved = inner.save(o);
cache.put(saved.id(), saved);
return saved;
}
}
Python — wrap with closure
def wrap_with_audit(fn, audit):
def wrapped(*a, **kw):
audit.log(f"{fn.__name__}.start")
try: return fn(*a, **kw)
finally: audit.log(f"{fn.__name__}.end")
return wrapped
pay = wrap_with_audit(legacy_pay, audit)
Sprout 의 test (TDD first)
@Test
void notifyCustomer_priorityOrder_sendsPriorityTemplate() {
var o = new Order(customer, true);
new OrderProcessor(repo, emailMock, smsMock).notifyCustomer(o);
verify(emailMock).send(customer.email(), "priority-thanks");
}
매 결정 기준
| 상황 | Approach |
|---|---|
| Add small new logic to legacy method | Sprout Method |
| New logic 의 large/independent | Sprout Class |
| Add before/after to specific method | Wrap Method |
| Cross-cutting (logging, cache, auth) across many callers | Wrap Class (decorator) |
| Legacy call sites 의 모두 update 의 가능 | Direct refactor 의 OK |
기본값: 매 legacy add → Sprout. 매 cross-cutting → Wrap Class.
🔗 Graph
- 부모: Refactoring_Best_Practices
- 변형: Sprout Method (스프라우트 메서드)
- Adjacent: Aspect-Oriented Programming (AOP)
🤖 LLM 활용
언제: 매 untested legacy code 의 modification 필요; 매 cross-cutting concern 의 add. 언제 X: 매 codebase 의 well-tested — 매 직접 refactor 의 cleaner.
❌ 안티패턴
- Wrap without rename: 매 infinite recursion.
- Sprout class 의 1-method-only forever: 매 결국 dead weight — 매 collapse 의 검토.
- Wrap class 의 not used by all callers: 매 inconsistent behavior — DI 의 enforce.
- No tests on sprouted/wrapped code: 매 entire technique 의 point 의 lost.
🧪 검증 / 중복
- Verified (Feathers, WELC ch.6–7, 2004; Fowler refactoring catalog).
- 신뢰도 A.
🕓 Changelog
| 날짜 | 변경 |
|---|---|
| 2026-05-08 | Phase 1 |
| 2026-05-10 | Manual cleanup — full Sprout & Wrap quartet with Java/Python patterns |