Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
design_pattern:visitor_pattern [2017/10/31 09:05] ledyxdesign_pattern:visitor_pattern [2021/02/07 03:30] (current) – [Visitor Pattern] ledyx
Line 1: Line 1:
 = Visitor Pattern = = Visitor Pattern =
-객체 구조를 돌아다니면서 동일한 조작을 반복해서 적용하기. 이 때, '객체 구조'와 '처리(Algorithm)'을 분리하는 것이 핵심. 개방-폐쇄 원칙(OCP, Open-Closed Principle)[(https://ko.wikipedia.org/wiki/%EA%B0%9C%EB%B0%A9-%ED%8F%90%EC%87%84_%EC%9B%90%EC%B9%99)]을 적용한 방법중 하나.+객체 구조를 돌아다니면서 동일한 조작을 반복해서 적용하기. 이 때, '객체 구조'와 '처리(Algorithm)'을 분리하는 것이 핵심. 개방-폐쇄 원칙(OCP, Open-Closed Principle)[(기존 클래스를 수정하지 않고 확장할 수 있도록 하는 것. https://ko.wikipedia.org/wiki/%EA%B0%9C%EB%B0%A9-%ED%8F%90%EC%87%84_%EC%9B%90%EC%B9%99)]을 적용한 방법중 하나.
  
   * 언제 사용하는가?   * 언제 사용하는가?
     * 데이터 구조 안에 많은 요소가 저장되어 있고, 그 각 요소에 대해서 __다른 종류의 <fc red>처리(Algorithm)</fc>__가 필요한 경우     * 데이터 구조 안에 많은 요소가 저장되어 있고, 그 각 요소에 대해서 __다른 종류의 <fc red>처리(Algorithm)</fc>__가 필요한 경우
 +    * 이로써 얻는 이점으로 객체 구조와 처리 역할을 독립적으로 확장 가능!
  
  
-{{tag>Architecture Modeling DesignPattern Behavioral}}+{{tag>Architecture Modeling Design_Pattern Behavioral}}
  
-  * 시나리오 +시나리오 
-    * [[composite pattern]]의 예제인 "파일 시스템" 탐색을 이용. 여기서 처리 알고리즘을 분리시킨다.+  * [[composite pattern]]의 예제인 "파일 시스템"을 객체 구조(Element, ObjectStructure)로 이용. 여기서 처리 알고리즘을 분리시킨다.
  
  
Line 94: Line 95:
  }  }
   
 + /* 객체 구조의 각 요소에 특정한 처리를 실행하는 데 필요 */
  /* Directory에서만 유효 */  /* Directory에서만 유효 */
  public Iterator<Entry> iterator() throws FileTreatmentException {  public Iterator<Entry> iterator() throws FileTreatmentException {
design_pattern/visitor_pattern.1509440715.txt.gz · Last modified: 2021/02/07 03:15 (external edit)