Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions Design Pattern/Composite Pattern.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Composite Pattern

### 목적
compositie pattern의 사용 목적은 object의 **hierarchies**를 표현하고 각각의 object를 독립적으로 동일한 인터페이스를 통해 처리할 수 있게한다.
composite pattern의 사용 목적은 object의 **hierarchies**를 표현하고 각각의 object를 독립적으로 동일한 인터페이스를 통해 처리할 수 있게한다.

아래 Composite pattern의 class diagram을 보자

Expand Down Expand Up @@ -30,7 +30,7 @@ public class Component {
}
}
```
Leaf 클래스와 Compositie 클래스가 상속하는 Component 클래스로 Leaf 클래스에서 사용하지 않는 메소드 호출 시 exception을 발생시키게 구현하였다.
Leaf 클래스와 Composite 클래스가 상속하는 Component 클래스로 Leaf 클래스에서 사용하지 않는 메소드 호출 시 exception을 발생시키게 구현하였다.

**Leaf 클래스**
```java
Expand Down Expand Up @@ -84,7 +84,7 @@ public class Composite extends Component {
## Children 관리를 위한 2가지 Composite pattern
![composite pattenr](../resources/composite_pattern_1.PNG)

위의 예제로 Component 클래스에 add, removem getChild 같은 method가 선언이 되어있으며 Transparency를 제공한다.
위의 예제로 Component 클래스에 add, remove, getChild 같은 method가 선언이 되어있으며 Transparency를 제공한다.

장점 : Leaf 클래스와 Composite 클래스를 구분할 필요없이 Component Class로 생각할 수 있다.

Expand All @@ -102,7 +102,7 @@ public class Composite extends Component {
### Decorator
공통점 : composition이 재귀적으로 발생한다.

차이점 : decorator 패턴은 responsibilites를 추가하는 것이 목표이지만 composite 패턴은 hierarchy를 표현하기 위해서 사용된다.
차이점 : decorator 패턴은 responsibilities를 추가하는 것이 목표이지만 composite 패턴은 hierarchy를 표현하기 위해서 사용된다.

### Iterator
공통점 : aggregate object을 순차적으로 접근한다.
공통점 : aggregate object을 순차적으로 접근한다.