> For the complete documentation index, see [llms.txt](https://krjaeh0.gitbook.io/j-log/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://krjaeh0.gitbook.io/j-log/programming/software-design/oop/coupling.md).

# coupling

## 결합도 란?

* 소프트웨어의 모듈(클래스, 함수, 컴포넌트 등)간의 의존성을 나타내는 개념
* 한 모듈이 다른 모듈과 얼마나 강하게 연결되어 있는지 측정하는 척도
* 결합도가 낮을 수록 유지보수가 용이
* 결합도가 높을 수록 모듈간 의존성이 강해지고 수정이 어려워 진다.
* **이상적인 설계는 "높은 응집도 + 낮은 결합도"를 갖는 시스템** 이다.

{% hint style="info" %}
이상적인 시스템 설계 원칙을 강조: 높은 응집도와 낮은 결합도를 목표로 한다.
{% endhint %}

***

## 결합도의 중요성

* 소프트웨어의 품질에 중요한 영향을 미치는 요소 중 하나

| 결합도 수준                          | 특징          | 장점               | 단점                             |
| ------------------------------- | ----------- | ---------------- | ------------------------------ |
| <p>높은 결합도<br>Tight Coupling</p> | 모듈 간 강한 의존성 | 성능 최적화 가능        | 유지 보수 어려움, 변경 시 다른 모듈에 영향을 준다. |
| <p>낮은 결합도<br>Loose Coupling</p> | 모듈 간 낮은 의존성 | 유지보수 용이, 재사용성 증가 | 초기 설계가 복잡해 질 수 있다.             |

***

## 결합도의 유형 (종류)

* 낮은 결합도(Low Coupling) → 높은 결합도(High Coupling) 순으로 분류할 수 있으며, 이상적인 소프트웨어 설계에서는 낮은 결합도가 좋음

| 결합도 유형                            | 설명                                                 | 결합도 강도    |
| --------------------------------- | -------------------------------------------------- | --------- |
| <p>내용 결합<br>Content Coupling</p>  | 한 모듈이 다른 모듈의 내부 데이터나 로직을 직접 참조                     | 가장 강함 결합도 |
| <p>공통 결합<br>Common Coupling</p>   | 여러 모듈이 동일한 전역 변수를 공유                               | 높은 결합도    |
| <p>외부 결합<br>External Coupling</p> | <p>모듈이 외부 환경에 의존<br>(DB, 파일, 하드웨어 등)</p>           | 높은 결합도    |
| <p>제어 결합<br>Control Coupling</p>  | <p>한 모듈이 다른 모듈의 실행 흐름을 직접 제어<br>(flag, switch)</p> | 중간 결합도    |
| <p>스탬프 결합<br>Stamp Coupling</p>   | 전체 데이터 구조가 아닌, 일부만 전달하는 방식                         | 낮은 결합도    |
| <p>자료 결합<br>Data Coupling</p>     | <p>모듈 간 단순한 데이터 값만 주고 받는 구조<br>(최소한이 정보 교환)</p>    | 가장 낮은 결합  |

{% hint style="success" %}
✔️ 이상적인 시스템은 "자료 결합(Data Coupling)"을 유지하는 것을 지향하며 설계한다.
{% endhint %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://krjaeh0.gitbook.io/j-log/programming/software-design/oop/coupling.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
