--- id: wiki-2026-0508-vfunction title: vFunction category: 10_Wiki/Topics status: verified canonical_id: self aliases: [virtual function, 가상 함수, vFunction.com] duplicate_of: none source_trust_level: A confidence_score: 0.9 verification_status: applied tags: [oop, polymorphism, architecture, modernization] raw_sources: [] last_reinforced: 2026-05-10 github_commit: pending tech_stack: language: cpp framework: none --- # vFunction ## 매 한 줄 > **"매 dispatch 의 runtime 의 resolve"**. 매 term 의 two meanings — (1) C++ `virtual` function (vtable-based dynamic dispatch), (2) vFunction.com (AI-driven Java monolith → microservices modernization platform). 매 context 의 disambiguate. ## 매 핵심 ### 매 (1) Virtual function (C++) - **vtable**: 매 class per — function pointer table. - **vptr**: 매 instance per — vtable 의 pointer. - **Dispatch**: `obj->fn()` → `obj->vptr[fn_index]()` (one extra indirection). - **Cost**: ~1-2 ns per call, 매 inlining 의 block. - **Override**: derived class 의 same signature 의 redefine. ### 매 (2) vFunction.com platform - **Static + dynamic analysis**: 매 Java/.NET monolith 의 scan. - **Domain extraction**: AI 의 bounded context 의 cluster. - **Refactor recommendation**: 매 service boundary + dead code + TCO. - **2025 update**: Claude/GPT-5 backed reasoning, 매 Spring Boot extraction template. ### 매 응용 (vfunc C++) 1. Strategy pattern. 2. Plugin/driver interface. 3. Mock injection 의 testing. ### 매 응용 (vFunction.com) 1. Legacy Java EE → microservice migration. 2. Technical debt quantification. 3. Architectural drift detection. ## 💻 패턴 ### Virtual function (modern C++20) ```cpp struct Shape { virtual ~Shape() = default; virtual double area() const = 0; // pure virtual }; struct Circle : Shape { double r; explicit Circle(double r) : r(r) {} double area() const override { return 3.14159 * r * r; } }; double total(std::span> shapes) { double s = 0; for (auto& sh : shapes) s += sh->area(); // dynamic dispatch return s; } ``` ### Devirtualization hint (final) ```cpp struct FastCircle final : Shape { // final → compiler 의 devirtualize double area() const override final { return 3.14; } }; ``` ### CRTP (static polymorphism, vfunc 의 X) ```cpp template struct Shape { double area() const { return static_cast(this)->area_impl(); } }; struct Square : Shape { double s; double area_impl() const { return s * s; } // zero overhead }; ``` ### Rust (trait object, vfunc analog) ```rust trait Shape { fn area(&self) -> f64; } struct Circle { r: f64 } impl Shape for Circle { fn area(&self) -> f64 { 3.14 * self.r * self.r } } fn total(shapes: &[Box]) -> f64 { shapes.iter().map(|s| s.area()).sum() // dyn dispatch via vtable } ``` ### vFunction.com workflow (concept) ```yaml # .vfunction/config.yaml target: java/spring-boot analyze: paths: [src/main/java] exclude: [test, generated] extract: strategy: domain-driven min-cohesion: 0.7 recommendations: - service-boundaries - dead-code - dependency-cycles ``` ## 매 결정 기준 | 상황 | Approach | |---|---| | Runtime polymorphism, OOP | virtual function | | Hot loop, type known | CRTP / template | | Plugin boundary | virtual + dyn lib | | Legacy Java refactor | vFunction.com | | Greenfield modular | DDD + bounded context | **기본값**: virtual function 의 default OOP, CRTP 의 perf-critical. ## 🔗 Graph - 부모: [[Object-Oriented-Programming]] · [[Polymorphism]] - Adjacent: [[Legacy Modernization]] ## 🤖 LLM 활용 **언제**: legacy code 의 virtual function chain 의 analyze, 매 modernization scope 의 estimate. **언제 X**: 매 micro-optimization decision (devirtualize 의 X) — 매 profiler 의 use. ## ❌ 안티패턴 - **Virtual everything**: 매 every method 의 virtual, 의 cost + 의 hard 의 reason. Final 의 default. - **Diamond inheritance**: 매 multiple virtual base, 의 composition 의 prefer. - **Virtual destructor 의 forget**: base class polymorphic, 의 leak. - **vFunction 의 silver bullet**: tool 의 recommendation 의 blindly 의 apply, 의 domain understanding 의 first. ## 🧪 검증 / 중복 - Verified (ISO C++ standard, Stroustrup "Tour of C++" 3rd, vfunction.com docs 2025). - 신뢰도 A. ## 🕓 Changelog | 날짜 | 변경 | |---|---| | 2026-05-08 | Phase 1 | | 2026-05-10 | Manual cleanup — full vFunction (virtual + platform) entry |