"매 high cohesion, low coupling". 1974년 Larry Constantine 의 structured design 으로 도입된 매 module quality metric 의 두 axis — module 내부 element 의 relatedness (cohesion) 와 module 간 dependency strength (coupling). 매 2026 microservice / domain-driven design 의 기본 vocabulary.
매 핵심
매 Cohesion (응집도) — 매 within
매 single module element 가 매 single purpose 를 향하는 정도.
매 Higher = better. 매 module 의 reason to change 의 한 가지로 수렴.
매 SRP (Single Responsibility Principle) 의 quantitative cousin.
매 Coupling (결합도) — 매 between
매 두 module 간 dependency strength.
매 Lower = better. 매 한 module 의 변경 의 다른 module 의 영향 의 최소화.
매 inter-module knowledge 의 minimization.
매 Cohesion 의 7 levels (low → high)
Coincidental — 매 unrelated, grouped randomly.
Logical — 매 same category 만 (e.g., all I/O).
Temporal — 매 same time 의 execution (e.g., init).
Procedural — 매 same control flow.
Communicational — 매 same data 의 작업.
Sequential — 매 output → next input.
Functional — 매 single well-defined task. 매 best.
매 Coupling 의 6 levels (high → low)
Content — 매 internal 의 직접 access. 매 worst.
Common — 매 global state 공유.
External — 매 external format 공유.
Control — 매 flag 로 behavior 제어.
Stamp — 매 struct 전체 전달 (subset 만 사용).
Data — 매 primitive parameter 만. 매 best.
💻 패턴
매 Functional Cohesion 예
# 매 Good — single purposeclassOrderTotalCalculator:defcalculate(self,items:list[OrderItem])->Money:subtotal=sum(item.price*item.qtyforiteminitems)tax=subtotal*Decimal("0.10")returnMoney(subtotal+tax,"USD")
매 Coincidental Cohesion (anti)
# 매 Bad — utility kitchen sinkclassHelpers:defformat_date(self,d):...defhash_password(self,pw):...defparse_json(self,s):...defsend_email(self,to):...
매 Data Coupling (best)
# 매 Good — primitive paramsdefdiscount(price:Decimal,rate:Decimal)->Decimal:returnprice*(1-rate)
매 Content Coupling (worst)
# 매 Bad — reaching into internalsclassA:def__init__(self):self._cache={}classB:defuse(self,a:A):a._cache["secret"]=1# 매 violation
매 Stamp → Data 의 refactor
# Before: stamp couplingdefship(order:Order):# 매 Order 전체 의존address=order.customer.address...# After: data couplingdefship(address:Address):...
# 매 Bounded context 별 serviceservices:order-service:# 매 functional cohesionresponsibility:order lifecyclepayment-service:responsibility:payment processingshipping-service:responsibility:fulfillment
매 결정 기준
상황
Approach
매 module 의 reason to change 의 multiple
매 Split — cohesion 향상
매 cross-module call 의 빈번
매 Merge or 의 facade — coupling 감소
매 global state 의존
매 Inject as dependency
매 flag parameter
매 Polymorphism / strategy 로 split
매 internal field 의 access
매 Encapsulation — getter/method
기본값: 매 high cohesion (functional) + 매 low coupling (data) 의 추구.