본문 바로가기

Programming/Design Pattern

Strategy Pattern 과제

과제 : strategy pattern을 이용해서 파일 속성을 다양한 형태로 비교해서 정렬해서 출력할 수 있는 프로그램을 작성할 것

FileInfo의 Class Diagram

 - 두 가지 방식으로 패턴을 작성하였음

(1) Sorter Interface에 정렬 알고리즘들을 구현한다. 본인이 푼 방식

코드 : https://github.com/kook1932/Computer-Science/tree/master/Design%20Pattern/Strategy%20Pattern01

 

(2) Comparable Interface에 정렬 기준에 따른 비교 알고리즘 구현

코드 : https://github.com/kook1932/Computer-Science/tree/master/Design%20Pattern/Strategy%20Pattern02

어떤 알고리즘을 더 전략적으로 쓸 것인가에 따라 설계를 조금씩 바꿔서 코드를 작성하면 될 것 같다.

'Programming > Design Pattern' 카테고리의 다른 글

Decorator Pattern  (0) 2019.12.27
Observer Pattern 과제  (0) 2019.12.27
Observer Pattern  (0) 2019.12.27
Strategy Pattern  (0) 2019.12.26
디자인 패턴을 배워야 하는 이유  (0) 2019.12.26