Files
2nd/10_Wiki/Topic_Programming/Architecture/Pull Up Method.md
T
Antigravity Agent 9148c358d0 docs(10_Wiki): 위키 전체 재구성 — Topic_* 폴더를 4개 카테고리로 통합 + 대규모 중복 제거
Topic_Agent/Topic_Blog/Topics/Topics_Biz/Topics_Meeting/Topics_Rag의 마크다운 지식 문서를
Topic_General/Topic_Programming/Topic_Graphic/Topic_Business 4개 카테고리로 재분류.

- 중복 제거: frontmatter의 status:duplicate/merged + duplicate_of/redirect_to 필드로
  자기 자신을 중복으로 선언한 리다이렉트 stub 1032개 제거, 완전 동일 내용 파일 472개 제거,
  동일 파일명·다른 내용 충돌 시 더 큰(완전한) 버전만 유지(162개 제거) — 총 1639개 중복 제거.
- 분류: 폴더 단위로 명확한 항목(AI_and_ML/Coding/Architecture 등 → Programming,
  Comfyui/Visual_Effects → Graphic, Topics_Biz/Topics_Meeting/사업 등 → Business,
  Poetic_Blog_Writing/창의성/Game_Design 등 → General)은 폴더 우선순위로,
  나머지 혼재 폴더(Topic_Agent/Topic_Blog/Topics 루트/Thinking & Reasoning/Other/UI_UX_Assets)는
  title/tags 키워드 스코어링으로 파일 단위 분류(불명확한 경우 General로 폴백).
  원본 폴더명은 "From_*" 서브폴더로 보존해 추적 가능성 유지.
- 최종 배치: Programming 2784 / General 1608 / Graphic 285 / Business 249 = 4926개 문서.
- 에이전트 운영 상태(.astra/.agent/.obsidian/sessions/memory/_company/docs/lessons/_shared/src)는
  지식 콘텐츠가 아니므로 재분류 대상에서 제외하고 원위치 유지.
- Topics/Topic_email(상위 보호 폴더 Topic_email과 파일명 100% 중복) 삭제 — 보호 폴더 자체는 미변경.
- 완전히 비게 된 Topic_Agent/Topic_Blog/Topics_Biz/Topics_Rag 폴더 제거.
2026-07-05 00:33:48 +09:00

4.9 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-pull-up-method Pull Up Method 10_Wiki/Topics verified self
Pull Up Refactoring
Method Hoisting
none A 0.9 applied
refactoring
oop
inheritance
2026-05-10 pending
language framework
java refactoring

Pull Up Method

매 한 줄

"매 duplicated method 매 sibling subclasses 안 — 매 superclass 로 hoist". Fowler의 Refactoring (1999, 2nd ed 2018) 매 catalog item. 매 Extract Superclass / Replace Inheritance with Delegation 와 매 짝.

매 핵심

매 trigger

  • 매 두 개 이상 sibling subclass 가 매 identical (or near-identical) method body 보유.
  • 매 fields 도 같이 pull up 가능 — Pull Up Field.
  • 매 constructor body 도 — Pull Up Constructor Body.

매 mechanics

  • 매 step 1: 매 method bodies 매 inspect — 매 truly identical 인지.
  • 매 step 2: 매 differences 매 parameterize — 매 identical 로 만들기.
  • 매 step 3: 매 superclass 매 method 작성, 매 subclasses 매 method 삭제.
  • 매 step 4: 매 test — 매 polymorphic dispatch 매 correct 인지.

매 응용

  1. ORM entity hierarchy — 매 BaseEntityid, createdAt pull up.
  2. UI component class hierarchy — 매 common rendering logic.
  3. Service layer — 매 audit/logging method pull up.

💻 패턴

Java — Pull Up Method

// Before
class Salesman extends Employee {
    String getName() { return name; }
}
class Engineer extends Employee {
    String getName() { return name; }
}

// After
class Employee {
    protected String name;
    String getName() { return name; }
}
class Salesman extends Employee {}
class Engineer extends Employee {}

Pull Up Field

// Before
class Salesman extends Employee {
    private String name;
}
class Engineer extends Employee {
    private String name;
}

// After
class Employee {
    protected String name;
}

Pull Up Constructor Body

class Employee {
    protected String name;
    protected Employee(String name) { this.name = name; }
}
class Manager extends Employee {
    private int grade;
    Manager(String name, int grade) {
        super(name);  // pulled up
        this.grade = grade;
    }
}

Python — pull up via ABC

from abc import ABC

class Shape(ABC):
    def describe(self) -> str:
        return f"Shape with area {self.area():.2f}"

class Circle(Shape):
    def __init__(self, r): self.r = r
    def area(self): return 3.14159 * self.r ** 2

class Square(Shape):
    def __init__(self, s): self.s = s
    def area(self): return self.s ** 2

TypeScript — abstract class

abstract class Animal {
    constructor(protected name: string) {}
    describe(): string {  // pulled up from Dog/Cat
        return `${this.name} is a ${this.constructor.name}`;
    }
    abstract makeSound(): string;
}
class Dog extends Animal { makeSound() { return "Woof"; } }
class Cat extends Animal { makeSound() { return "Meow"; } }

Refactoring with parameterization

// Before — almost identical
class A { int charge() { return base * 1.05; } }
class B { int charge() { return base * 1.10; } }

// Step: parameterize
class A extends Billing { int charge() { return calc(1.05); } }
class B extends Billing { int charge() { return calc(1.10); } }

// Pull up
class Billing { protected int calc(double rate) { return base * rate; } }

매 결정 기준

상황 Approach
매 identical method 매 2+ sibling Pull Up Method
매 similar but different method Form Template Method 먼저
매 only 1 subclass uses Don't pull up
매 deep inheritance (>3 levels) Composition 고려
매 LSP 위반 risk Don't — Extract Class instead

기본값: 매 2+ siblings 매 identical body — Pull Up. 매 그 외 — composition.

🔗 Graph

🤖 LLM 활용

언제: 매 sibling classes 매 duplication detection — LLM 매 structural similarity 매 잘 detect. 매 IDE refactor (IntelliJ, Rider) 매 mechanical transform 자동. 언제 X: 매 cross-cutting concern (logging, auth) — Pull Up 대신 매 aspect / decorator.

안티패턴

  • Forced inheritance: 매 unrelated classes 매 method 공유 위해 매 fake superclass — composition 사용.
  • God superclass: 매 너무 많이 pull up — base class 가 매 dumping ground 가 됨.
  • LSP violation: 매 pulled-up method 가 매 some subclass 에서 매 invalid — split.

🧪 검증 / 중복

  • Verified (Fowler — Refactoring 2nd ed, 2018, ch 12).
  • 신뢰도 A.

🕓 Changelog

날짜 변경
2026-05-08 Phase 1
2026-05-10 Manual cleanup — full refactoring catalog entry