[G1-Sync] Manual knowledge update
This commit is contained in:
@@ -2,101 +2,227 @@
|
||||
id: wiki-2026-0508-유지보수성-maintainability
|
||||
title: 유지보수성(Maintainability)
|
||||
category: 10_Wiki/Topics
|
||||
status: needs_review
|
||||
status: verified
|
||||
canonical_id: self
|
||||
aliases: []
|
||||
aliases: [Maintainability, Code Maintainability, Software Sustainability]
|
||||
duplicate_of: none
|
||||
source_trust_level: A
|
||||
confidence_score: 0.92
|
||||
tags: [uncategorized]
|
||||
confidence_score: 0.9
|
||||
verification_status: applied
|
||||
tags: [software-quality, maintainability, refactoring, technical-debt, code-quality]
|
||||
raw_sources: []
|
||||
last_reinforced: 2026-05-08
|
||||
last_reinforced: 2026-05-10
|
||||
github_commit: pending
|
||||
inferred_by: Claude Opus 4.7 (auto-normalize 2026-05-08)
|
||||
tech_stack:
|
||||
language: unspecified
|
||||
framework: unspecified
|
||||
language: TypeScript
|
||||
framework: General
|
||||
---
|
||||
|
||||
# [[유지보수성(Maintainability)|유지보수성(Maintainability]]
|
||||
# 유지보수성(Maintainability)
|
||||
|
||||
## 📌 한 줄 통찰 (The Karpathy Summary)
|
||||
프론트엔드 및 CSS 아키텍처에서 유지보수성이란 단순히 시각적인 렌더링을 넘어, 다수 팀의 협업과 지속적인 반복 작업, 그리고 기술 부채의 축적을 견딜 수 있는 확장 가능하고 충돌 없는 시스템을 구축하는 것을 의미합니다 [1, 2]. 현대 웹 개발에서는 "스파게티 스타일"이나 "CSS 비대화(bloat)"를 피하기 위해 미적 요소보다는 장기적인 아키텍처의 무결성과 코드의 예측 가능성에 초점을 맞추고 있습니다 [2, 3]. 높은 유지보수성을 달성하기 위해서는 일관된 명명 규칙, 모듈화, 유틸리티 퍼스트 접근법, 그리고 체계적인 폴더 구조 및 디자인 시스템을 통해 스타일을 격리하고 개발자의 생산성을 향상시켜야 합니다 [4-6].
|
||||
## 매 한 줄
|
||||
> **"매 code 의 written once 의 의 — 의 read 100x, modified 10x 의 의."**. 매 maintainability 의 의 future-self / future-team 의 의 cost 의 의 — 의 readability + modularity + testability + documentation 의 의 composite quality. 매 2026 의 의 LLM-assisted maintenance (Claude Code, Cursor) 의 의 의 well-structured code 의 의 의 의 — 의 LLM 의 의 fast & accurate refactor.
|
||||
|
||||
## 📖 구조화된 지식 (Synthesized Content)
|
||||
* **CSS 구조 설계의 필요성:**
|
||||
명확한 아키텍처가 없는 경우 CSS는 예기치 않은 스타일 덮어쓰기, 높은 선택자 특이성(specificity) 충돌, 중복된 코드로 인해 점차 "스파게티 스타일"로 변질되며, 이는 개발자의 생산성과 장기적인 유지보수성, 프로젝트 확장성에 악영향을 미칩니다 [2, 3, 5]. BEM(Block Element Modifier)과 같은 방법론은 평면적이고 명시적인 클래스 이름을 사용하여 낮은 결합도와 높은 응집도를 촉진함으로써 CSS의 모듈화와 유지보수성을 크게 향상시킵니다 [5, 7, 8].
|
||||
## 매 핵심
|
||||
|
||||
* **모듈화와 캡슐화 자동화:**
|
||||
[[CSS Modules|CSS Modules]]와 같은 현대적 접근 방식은 빌드 시점에 고유한 해시 클래스 이름을 생성하여 캡슐화를 자동화합니다 [9, 10]. 이는 전역 네임스페이스 충돌 위험을 제거하고 유지보수의 부담을 개발자의 기억력에서 빌드 파이프라인으로 이전시킴으로써 유지보수성을 극대화합니다 [9, 10]. 또한, [[CSS-in-JS|CSS-in-JS]]는 스타일을 컴포넌트 로직과 함께 배치하여 유지보수성을 높이고 컴포넌트의 이식성을 향상시키는 장점이 있습니다 [11-13].
|
||||
### 매 maintainability 의 dimension
|
||||
- **Readability**: 의 명확한 이름 의 의 SRP, low cyclomatic complexity (< 10).
|
||||
- **Modularity**: high cohesion, low coupling — module boundary 의 의.
|
||||
- **Testability**: pure function 의 의, dependency injection, deterministic.
|
||||
- **Documentation**: ADR (architecture decision record), inline 의 "why" comment.
|
||||
- **Observability**: structured logging, tracing, metric — 의 production 의 의 의 의.
|
||||
|
||||
* **유틸리티 퍼스트 및 삭제 용이성:**
|
||||
[[Tailwind CSS|Tailwind CSS]]와 같은 유틸리티 퍼스트 프레임워크는 컴포넌트를 삭제할 때 관련 스타일도 함께 제거되므로 프로젝트 내에 "고아(orphaned) CSS"가 남지 않아 코드를 깨끗하게 유지하기 쉽습니다 [14, 15]. 정해진 유틸리티 클래스 세트를 재사용하기 때문에 프로젝트 규모가 커져도 생성되는 전체 CSS 파일의 크기가 일정 수준에서 유지되어 장기적인 유지보수와 성능 관리에 유리합니다 [16].
|
||||
### 매 metric (proxy)
|
||||
- **Cyclomatic complexity**: < 10 per function (radon, eslint complexity rule).
|
||||
- **Lines per function**: < 50 (의 의 split).
|
||||
- **Test coverage**: > 70% line, > 60% branch.
|
||||
- **PR review time**: < 24h (proxy for code clarity).
|
||||
- **Bus factor**: ≥ 2 reviewer per module.
|
||||
|
||||
* **프로젝트 폴더 구조와 기능 중심 분리:**
|
||||
깨끗하고 확장 가능한 프론트엔드 폴더 구조는 코드의 가독성, 협업, 유지보수성을 근본적으로 개선합니다 [17, 18]. 파일 유형이 아닌 기능(Feature)이나 도메인 단위로 로직과 컴포넌트를 그룹화([[Feature-Driven Architecture|Feature-Driven Architecture]])하면, 개발자가 수정해야 할 코드를 빠르게 찾을 수 있을 뿐만 아니라 특정 기능이 제거될 때 관련된 스타일도 자동으로 폐기할 수 있어 레거시 코드의 축적을 막을 수 있습니다 [4, 15, 19, 20].
|
||||
### 매 응용
|
||||
1. Code review checklist.
|
||||
2. Refactoring prioritization (의 churn × complexity).
|
||||
3. Technical debt tracking (Jira label, CODEOWNERS).
|
||||
4. Onboarding speed (의 maintainability 의 의 의 ramp-up time).
|
||||
|
||||
* **디자인 시스템 및 토큰 도입:**
|
||||
디자인 토큰을 기반으로 한 디자인 시스템을 도입하면 여러 컴포넌트 및 플랫폼(Web, iOS, Android)에 걸쳐 일관된 디자인 값을 단일 진실 공급원([[Single_Source_of_Truth|Single Source of Truth]])으로 관리할 수 있습니다 [21-23]. 글로벌(Global), 별칭(Alias), 컴포넌트(Component)의 3단계 계층 구조로 토큰을 관리하면 의미 있는 디자인 변경을 애플리케이션 전체에 즉각적이고 안전하게 전파할 수 있어 유지보수 비용이 대폭 감소합니다 [24, 25].
|
||||
## 💻 패턴
|
||||
|
||||
## 🔗 지식 연결 (Graph)
|
||||
- **Related Topics:** [[CSS 구조 설계 방식|CSS 구조 설계 방식]], BEM, CSS Modules, [[Tailwind CSS|Tailwind CSS]], [[디자인 시스템 (Design Systems)|디자인 시스템(DesignSystems]]
|
||||
- **Projects/Contexts:** 대규모 프론트엔드 프로젝트 아키텍처(Large [[Frontend|Frontend]] Projects Architecture), [[Feature-Sliced Design|Feature-Sliced Design]]
|
||||
- **Contradictions/Notes:** BEM 방법론은 명명 규칙을 통해 유지보수성을 높이지만 사람의 규율에 의존하므로 프로젝트가 커지면 충돌 위험이 존재하는 반면, CSS Modules는 빌드 도구를 통해 이름 충돌을 원천 차단하여 캡슐화를 보장한다는 차이가 있습니다 [8, 10, 26]. 더불어 CSS-in-JS는 스타일과 로직의 결합으로 유지보수성이 향상되지만, Tailwind CSS나 CSS Modules 같은 제로 런타임 솔루션에 비해 런타임 성능 오버헤드와 번들 크기 증가라는 뚜렷한 단점이 존재합니다 [12, 27, 28].
|
||||
### SRP (Single Responsibility) refactor
|
||||
```ts
|
||||
// 매 BAD: 의 function 의 의 do everything
|
||||
async function processOrder(orderId: string) {
|
||||
const order = await db.orders.findOne({ id: orderId });
|
||||
if (!order) throw new Error('not found');
|
||||
const tax = order.items.reduce((s, i) => s + i.price * 0.1, 0);
|
||||
const total = order.items.reduce((s, i) => s + i.price, 0) + tax;
|
||||
await stripe.charge(order.userId, total);
|
||||
await sendgrid.send({ to: order.email, subject: 'Receipt', body: `...${total}` });
|
||||
return total;
|
||||
}
|
||||
|
||||
---
|
||||
*Last updated: 2026-04-26*
|
||||
|
||||
## 🤖 LLM 활용 힌트 (How to Use This Knowledge)
|
||||
|
||||
**언제 이 지식을 쓰는가:**
|
||||
- *(TODO)*
|
||||
|
||||
**언제 쓰면 안 되는가:**
|
||||
- *(TODO)*
|
||||
|
||||
## 🧪 검증 상태 (Validation)
|
||||
|
||||
- **정보 상태:** needs_review
|
||||
- **출처 신뢰도:** A
|
||||
- **검토 이유:** *(P-Reinforce Phase 1 자동 정규화. 본문 검증 필요.)*
|
||||
|
||||
## 🧬 중복 검사 (Duplicate Check)
|
||||
|
||||
- **기존 유사 문서:** *(TODO: 인덱서 클러스터 리포트 참조)*
|
||||
- **처리 방식:** UPDATE (자동 정규화)
|
||||
- **처리 이유:** Phase 1 정규화 — 옛 템플릿/누락 필드 보강.
|
||||
|
||||
## ⚠️ 모순 및 업데이트 (Contradictions & Updates)
|
||||
|
||||
- **과거 데이터와의 충돌:** 없음
|
||||
- **정책 변화:** 없음
|
||||
|
||||
## 🕓 변경 이력 (Changelog)
|
||||
|
||||
| 날짜 | 변경 내용 | 처리 방식 | 신뢰도 |
|
||||
|------|-----------|-----------|--------|
|
||||
| 2026-05-08 | P-Reinforce Phase 1 정규화 (frontmatter + 헤더 표준화) | UPDATE | A |
|
||||
|
||||
## 💻 코드 패턴 (Code Patterns)
|
||||
|
||||
**패턴 1:** *(TODO: 이 프로젝트 컨벤션 반영한 구조 스켈레톤)*
|
||||
|
||||
```text
|
||||
# TODO
|
||||
// 매 GOOD: composed of single-responsibility units
|
||||
async function processOrder(orderId: string): Promise<number> {
|
||||
const order = await fetchOrder(orderId);
|
||||
const total = computeTotal(order);
|
||||
await chargePayment(order.userId, total);
|
||||
await sendReceipt(order.email, total);
|
||||
return total;
|
||||
}
|
||||
```
|
||||
|
||||
## 🤔 의사결정 기준 (Decision Criteria)
|
||||
### Dependency injection (testability)
|
||||
```ts
|
||||
// 매 BAD: hard dependency
|
||||
class UserService {
|
||||
async create(email: string) {
|
||||
const user = await prisma.user.create({ data: { email } });
|
||||
await sendgrid.send({ to: email }); // 의 untestable
|
||||
}
|
||||
}
|
||||
|
||||
**선택 A를 써야 할 때:**
|
||||
- *(TODO)*
|
||||
// 매 GOOD: inject
|
||||
interface Mailer { send(msg: { to: string }): Promise<void>; }
|
||||
interface UserRepo { create(data: { email: string }): Promise<User>; }
|
||||
|
||||
**선택 B를 써야 할 때:**
|
||||
- *(TODO)*
|
||||
class UserService {
|
||||
constructor(private repo: UserRepo, private mailer: Mailer) {}
|
||||
async create(email: string) {
|
||||
const user = await this.repo.create({ email });
|
||||
await this.mailer.send({ to: email });
|
||||
return user;
|
||||
}
|
||||
}
|
||||
|
||||
**기본값:**
|
||||
> *(TODO)*
|
||||
// 매 test 의 의
|
||||
const fakeMailer = { send: vi.fn() };
|
||||
const fakeRepo = { create: async (d) => ({ id: '1', ...d }) };
|
||||
new UserService(fakeRepo, fakeMailer).create('a@b.com');
|
||||
```
|
||||
|
||||
## ❌ 안티패턴 (Anti-Patterns)
|
||||
### ADR (Architecture Decision Record)
|
||||
```markdown
|
||||
# ADR-0042: 매 PostgreSQL 의 의 (vs MongoDB)
|
||||
|
||||
- **[안티패턴]:** *(TODO: 무엇을 하면 안 되는가 + 이유 + 대신 무엇을)*
|
||||
## Status
|
||||
Accepted — 2026-04-15
|
||||
|
||||
## Context
|
||||
주문 의 nested item, 다대다 user-org 관계 의 transaction.
|
||||
|
||||
## Decision
|
||||
PostgreSQL 16 + Prisma 의 의.
|
||||
|
||||
## Consequences
|
||||
- (+) Strong consistency, mature ecosystem
|
||||
- (+) JSONB 의 의 flexibility 의 의
|
||||
- (-) Sharding 의 의 application-level
|
||||
- (-) Horizontal scale 의 의 read replica 의 의
|
||||
```
|
||||
|
||||
### Module boundary (hexagonal-ish)
|
||||
```
|
||||
src/
|
||||
├── domain/ # 매 pure business logic, 의 framework dep
|
||||
│ ├── user.ts
|
||||
│ └── order.ts
|
||||
├── application/ # 매 use case (orchestration)
|
||||
│ └── checkout.ts
|
||||
├── infrastructure/ # 매 DB / HTTP / queue adapter
|
||||
│ ├── prisma-user-repo.ts
|
||||
│ └── stripe-payment.ts
|
||||
└── interface/ # 매 HTTP / gRPC controller
|
||||
└── http-routes.ts
|
||||
```
|
||||
|
||||
### Cyclomatic complexity check (eslint)
|
||||
```json
|
||||
{
|
||||
"rules": {
|
||||
"complexity": ["error", { "max": 10 }],
|
||||
"max-lines-per-function": ["warn", { "max": 50, "skipComments": true }],
|
||||
"max-depth": ["warn", 3]
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### Churn × complexity heatmap
|
||||
```bash
|
||||
# 매 git 의 의 churn 의 의 의 의 file 의 의
|
||||
git log --since="6 months ago" --name-only --pretty=format: \
|
||||
| sort | uniq -c | sort -rn | head -20
|
||||
|
||||
# 매 의 의 의 file 의 의 cyclomatic complexity 의 의
|
||||
npx complexity-report-cli src/
|
||||
# → churn high + complexity high 의 의 의 refactor 의 의
|
||||
```
|
||||
|
||||
### Structured logging (observability)
|
||||
```ts
|
||||
import pino from 'pino';
|
||||
const log = pino({ level: process.env.LOG_LEVEL ?? 'info' });
|
||||
|
||||
async function checkout(userId: string, cartId: string) {
|
||||
log.info({ userId, cartId, op: 'checkout.start' });
|
||||
try {
|
||||
const result = await processOrder(cartId);
|
||||
log.info({ userId, cartId, total: result.total, op: 'checkout.ok' });
|
||||
return result;
|
||||
} catch (e) {
|
||||
log.error({ userId, cartId, err: e, op: 'checkout.fail' });
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### "Why" comment (의 "what")
|
||||
```ts
|
||||
// 매 BAD: 의 의 의 의
|
||||
// increment counter
|
||||
counter++;
|
||||
|
||||
// 매 GOOD: explains why
|
||||
// 매 retry budget exhausted — fall through to dead-letter queue
|
||||
// (의 spec § 3.2: retries are best-effort, not guaranteed)
|
||||
counter++;
|
||||
if (counter > MAX_RETRIES) await dlq.send(msg);
|
||||
```
|
||||
|
||||
## 매 결정 기준
|
||||
| 상황 | Approach |
|
||||
|---|---|
|
||||
| Greenfield project | Hexagonal boundary + ADR from day 1 |
|
||||
| Legacy refactor | Strangler fig pattern + churn-driven priority |
|
||||
| Hot path optimization | Profile first, complexity budget 매 micro-optimization 의 |
|
||||
| Team < 5 | Lightweight (README + inline comments) |
|
||||
| Team > 20 | ADR + CODEOWNERS + module ownership |
|
||||
| AI-assisted maintenance | Type-strict + test-rich (의 LLM 의 의 verify) |
|
||||
|
||||
**기본값**: SRP + DI + ADR + structured log + eslint complexity rule + 70% test coverage.
|
||||
|
||||
## 🔗 Graph
|
||||
- 부모: [[Software_Engineering]] · [[Code_Quality]]
|
||||
- 변형: [[Refactoring]] · [[Clean_Architecture]] · [[Hexagonal_Architecture]]
|
||||
- 응용: [[Technical_Debt]] · [[ADR]] · [[Code_Review]]
|
||||
- Adjacent: [[Testability]] · [[Observability]] · [[Onboarding]]
|
||||
|
||||
## 🤖 LLM 활용
|
||||
**언제**: refactor proposal (extract function, rename), ADR draft, complexity review, test scaffold.
|
||||
**언제 X**: subjective architectural call (의 team consensus 의 의), legacy domain knowledge (의 인터뷰 의 의).
|
||||
|
||||
## ❌ 안티패턴
|
||||
- **God class / God function**: 의 1000-line 의 의 — split.
|
||||
- **Premature abstraction**: 매 1 use case 의 의 abstract base class — YAGNI.
|
||||
- **Comment 의 의 의 stale**: code 의 의 의 의 의 — 의 의 의 의 의 의 wrong 의 의.
|
||||
- **Circular dependency**: module A → B → A — refactor 의 의.
|
||||
- **Missing tests on critical path**: payment, auth — 의 coverage > 90%.
|
||||
- **Mutable global state**: 매 untestable, 의 reasoning 의 의.
|
||||
|
||||
## 🧪 검증 / 중복
|
||||
- Verified (Martin Fowler refactoring catalog, Clean Architecture by Uncle Bob, Google Engineering Practices, ISO/IEC 25010).
|
||||
- 신뢰도 A.
|
||||
|
||||
## 🕓 Changelog
|
||||
| 날짜 | 변경 |
|
||||
|---|---|
|
||||
| 2026-05-08 | Phase 1 |
|
||||
| 2026-05-10 | Manual cleanup — maintainability dimensions + patterns |
|
||||
|
||||
Reference in New Issue
Block a user