This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| design_pattern:composite_pattern [2017/10/29 13:03] – [Composite Pattern] ledyx | design_pattern:composite_pattern [2021/02/07 03:25] (current) – [Composite Pattern] ledyx | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| = Composite Pattern = | = Composite Pattern = | ||
| - | 그릇(복수)과 내용물(단수)을 동일시해서 재귀적인 구조 구축. | + | 그릇(<fc red>복수</fc>)과 내용물(<fc red>단수</fc>)을 동일시(= 혼합물, Composite)해서 재귀적인 구조 구축. |
| - | * <fc red>Tree 구조의 Data</ | + | * <fc red>Tree 구조의 Data(= 재귀적)</fc> |
| + | * File System | ||
| * Test Case 3개가 있을 때, 이를 모두 합쳐서 Test하고 싶은 경우 | * Test Case 3개가 있을 때, 이를 모두 합쳐서 Test하고 싶은 경우 | ||
| * GUI 프로그래밍에서 View안에 자식 View를 갖는 경우 | * GUI 프로그래밍에서 View안에 자식 View를 갖는 경우 | ||
| - | {{tag> | + | {{tag> |
| = Component = | = Component = | ||
| Line 66: | Line 67: | ||
| 그릇. Leaf나 Composite 역할을 넣을 수 있음. | 그릇. Leaf나 Composite 역할을 넣을 수 있음. | ||
| - | <sxh java ; highlight:[20-23]> | + | <sxh java ; highlight:[4, 21-24]> |
| public class Directory extends Entry { | public class Directory extends Entry { | ||
| Line 86: | Line 87: | ||
| } | } | ||
| + | /* Directory와 File을 같은 내용물로 간주 */ | ||
| public Entry add(Entry entry) { | public Entry add(Entry entry) { | ||
| directory.add(entry); | directory.add(entry); | ||
| Line 124: | Line 126: | ||
| } | } | ||
| } | } | ||
| + | |||
| + | |||
| + | /* | ||
| + | /root (3) | ||
| + | /root/bin (2) | ||
| + | / | ||
| + | / | ||
| + | /root/tmp (0) | ||
| + | /root/usr (0) | ||
| + | */ | ||
| </ | </ | ||