> For the complete documentation index, see [llms.txt](https://kimtaesu.gitbook.io/workspace/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://kimtaesu.gitbook.io/workspace/undefined/13.-srp-single-responsibility-principle.md).

# 클린 코더스 13. SRP(Single Responsibility Principle)

### 하나의 객체는 하나의 책임만 갖는다.

![](/files/-LoGxk0hv6-2dzg2vokm)

### EmployeeImpl Class 책임

EmployeeImpl 은 3개의 **책임**을 가지고 있으며 3개의 사용자에 의해 **변경의 근원**이 있다.

* CalculatePay
* Save/findById
* DescribeEmployee

### 책임을 발견하는 방법&#x20;

### 사용자가 특정 **역할**을 수행할 때 **Actor** 라고 부른다<br>

![](/files/-LowOLFQ5C-5_1ev3oJx)

역할은 Inverted Dependency 를 통해서 runtime 의존성을 가져야 한다.

### Inverted Dependency

![](/files/-LowOxCX3UevgeMqr0cL)

누가 변경을 유발하는 사용자인가?

사용자가 특정 **역할**을 수행할 때 **Actor** 라고 부른다<br>

> 책임과 역할의 용어 해석

<div align="left"><img src="/files/-LoGzXlxcJUC-GeFFr0n" alt="Strategy pattern"></div>

**책임**은 각각의 객체 ConcreateStrategyA, ConcreateStrategyB  이다.

하나의 책임만 가질 수 있다.

**역할**은 여러 책임을 가진 Context 객체이다.&#x20;

책임들의 추상화된 속성들을 가지며 역할을 수행한다.

<div align="left"><img src="/files/-LoH-oumom9Gkp0NhTip" alt="Template Method Pattern"></div>
