Files
2nd/10_Wiki/Topics/Architecture/Seam (접점).md
T
Antigravity Agent f8b21af4be Wiki cleanup: error-doc removal, dedup merge, link normalization
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>
2026-05-20 23:52:15 +09:00

5.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-seam-접점 Seam (접점) 10_Wiki/Topics verified self
Seam
Seams
이음새
접점
Feathers seam
none A 0.9 applied
legacy-code
refactoring
testing
feathers
2026-05-10 pending
language framework
typescript none

Seam (접점)

매 한 줄

"매 코드를 매 수정하지 않고 매 동작을 바꿀 수 있는 지점". Michael Feathers (Working Effectively with Legacy Code, 2004)의 핵심 개념. Seam은 매 legacy code에 매 test를 매 끼워넣는 매 hinge — 매 dependency를 매 엮어내는 매 join point.

매 핵심

매 정의

  • 매 place where you can alter behavior without editing in place.
  • 매 enabling point: 매 그 seam을 매 어떻게 활성화하는지 결정.

매 3 종류 (Feathers)

  1. Preprocessing Seam — compile/macro/언어 전처리 (C/C++ #define).
  2. Link Seam — link-time substitution (매 alt library, jest module mock).
  3. Object Seam — polymorphism (매 interface/subclass).

매 응용

  1. 매 legacy에 매 test 추가 — 매 substitute dependency.
  2. 매 hexagonal port — 매 object seam.
  3. 매 feature flag — 매 conditional seam.

💻 패턴

매 Object Seam — interface 추출

// X — 매 직접 의존
class OrderService {
  place(o: Order) {
    new SmtpMailer().send(o.user, "ordered"); // 매 hard-wired
  }
}

// O — 매 object seam
interface Mailer { send(to: string, msg: string): void; }
class OrderService {
  constructor(private mailer: Mailer) {}
  place(o: Order) { this.mailer.send(o.user, "ordered"); }
}
// 매 test에서 fake Mailer 주입.
// orderService.ts
import { sendEmail } from "./mailer";
export function place(o: Order) { sendEmail(o.user, "ordered"); }

// orderService.test.ts
import { place } from "./orderService";
jest.mock("./mailer", () => ({ sendEmail: jest.fn() }));
import { sendEmail } from "./mailer";

test("places", () => {
  place({ user: "a@b.com" } as any);
  expect(sendEmail).toHaveBeenCalledWith("a@b.com", "ordered");
});

매 Preprocessing Seam — TS compiler hook

// 매 build-time substitution (매 e.g., babel plugin / tsx loader)
// __ENV__ macro 가 매 build 시 replace
declare const __TEST__: boolean;
export function log(msg: string) {
  if (__TEST__) return;
  console.log(msg);
}

매 React Context seam

const ApiContext = createContext<Api>(realApi);

// 매 production
<ApiContext.Provider value={realApi}><App /></ApiContext.Provider>

// 매 test (Storybook/jsdom)
<ApiContext.Provider value={fakeApi}><App /></ApiContext.Provider>

매 NodeJS DI container seam (NestJS)

// 매 production
@Module({ providers: [{ provide: "Mailer", useClass: SmtpMailer }] })
class AppModule {}

// 매 test
const moduleRef = await Test.createTestingModule({
  providers: [OrderService, { provide: "Mailer", useValue: { send: jest.fn() } }],
}).compile();

매 Wrap method (Feathers technique)

// X — private method 가 매 hard-coded
class OrderService {
  place(o: Order) { this.notify(o); /* ... */ }
  private notify(o: Order) { new SmtpMailer().send(o.user, "ordered"); }
}

// O — 매 protected → subclass에서 override
class OrderService {
  place(o: Order) { this.notify(o); /* ... */ }
  protected notify(o: Order) { new SmtpMailer().send(o.user, "ordered"); }
}
class TestOrderService extends OrderService {
  protected notify() { /* swallow */ }
}

매 Feature flag seam

const flags = await flagClient.evaluate("new-checkout", { user });
const checkout = flags ? new NewCheckout() : new LegacyCheckout();

매 결정 기준

상황 Seam
매 OOP + DI 가능 Object Seam (interface).
매 legacy without DI Link Seam (module mock).
매 C/C++ 매 macro Preprocessing Seam.
매 React component Context seam.
매 cross-cutting toggle Feature flag seam.

기본값: 매 Object Seam — 매 testability + 매 long-term cleanest.

🔗 Graph

🤖 LLM 활용

언제: 매 legacy에 매 test 끼워넣기, 매 dependency 분리, 매 refactor 진입점 식별. 언제 X: 매 greenfield (매 처음부터 DI로 설계).

안티패턴

  • 매 seam 강제 too many: 매 abstraction noise.
  • 매 enabling point 미정: 매 seam 만들고 매 활용 X.
  • 매 monkey-patching seam (Ruby/Python): 매 long-term 유지보수 X.

🧪 검증 / 중복

  • Verified (Feathers, Working Effectively with Legacy Code, 2004, Ch. 4).
  • 신뢰도 A.

🕓 Changelog

날짜 변경
2026-05-08 Phase 1
2026-05-10 Manual cleanup — Feathers 3-seam canonical + modern patterns