4. 4
lahuman.jabsiri.co.kr
Adapter Pattern-2
- How can make? -
Class Adapter
자바의 상속을 이용하여 인터페이스 구현
Object Adapter
객체를 내부 멤버 변수로 선언하고 인터페이스 구현
두 방식의 결과는 같음
소스 : https://github.com/lahuman/study4DesignPattern/tree/master/StructuralDesignPatterns/src/kr/pe/lahuman/adapter
5. 5
lahuman.jabsiri.co.kr
Composite Pattern-1
- What is Composite Pattern? -
객체와 객체의 그룹을 구분없이 하나의 인터페이스로 구분 없
이 사용
Composite Pattern 은 대부분 다음의 객체로 구성
Base Component – Leaf 객체에 구성이 되는 인터페이스
Leaf – Base Component 를 상속받아 동작을 구현
Composite – base Component 의 그룹을 가지고 있으며 그룹을
관리와 명령 (operation) 을 실행
6. 6
lahuman.jabsiri.co.kr
Composite Pattern-2
- How can make? -
이해를 돕기 위한 예제 :
원 , 라인 , 삼각형 등 의 선택된 객체에 모두 같은 색으로 채
우는 프로그램
소스 : https://github.com/lahuman/study4DesignPattern/tree/master/StructuralDesignPatterns/src/kr/pe/lahuman/composite
7. 7
lahuman.jabsiri.co.kr
Proxy Pattern-1
- What is Proxy Pattern? -
실제 사용하려는 객체를 대신해서 역활을 해주는 패턴
사용 예
Virtual Proxy – 객체 생성에 많은 비용이 발생시 사용
Remote Proxy – 원격객체에 대한 로컬의 대리자 역활
Protection Proxy – 접근제어가 필요한 객체에 대한 접근을 통제
Smart Reference – 실제객체에 접근할때 부가적인 기능 수행
8. 8
lahuman.jabsiri.co.kr
Proxy Pattern-2
- How can make? -
이해를 돕기 위한 예제 :
- 클라이언트에서 서버에 특정 명령을 실행하는 클래스
- 서버의 시스템 파일을 지우는 명령이 실행 될 경우 문제가 발생
- Proxy 클래스를 생성하고 허용된 사용자에게만 프로그램 허용
소스 : https://github.com/lahuman/study4DesignPattern/tree/master/StructuralDesignPatterns/src/kr/pe/lahuman/proxy
9. 9
lahuman.jabsiri.co.kr
Flyweight Pattern-1
- What is Flyweight Pattern? -
효율적으로 세분화된 많은 수의 객체를 지원하기 위해 공유를
사용 하는 패턴
한번 생성된 객체는 두번 생성하지않고 풀 (POOL) 을 이용한 관
리
큰 객체를 몇개 생성할 경우
많은 메모리를 사용하는 객체를 생성하고 생성에 많은 시간이
소요될 경우
10. 10
lahuman.jabsiri.co.kr
Flyweight Pattern-2
- How can make? -
이해를 돕기 위한 예제 :
- 공유 객체를 return 하는 flyweight factory 클래스 생성
- Shape 를 구현한 Line 과 Oval 객체가 있고 , Oval 은 색상에 대한
외부 요소를 가짐
소스 : https://github.com/lahuman/study4DesignPattern/tree/master/StructuralDesignPatterns/src/kr/pe/lahuman/flyweight
12. 12
lahuman.jabsiri.co.kr
All text and image content in this document is licensed under the Creative Commons Attribution-Share Alike 3.0 License
(unless otherwise specified). "LibreOffice" and "The Document Foundation" are registered trademarks. Their respective logos
and icons are subject to international copyright laws. The use of these therefore is subject to the trademark policy.
감사합니다 .
이전 자료 : http://www.slideshare.net/lahuman1
블로그 : http://lahuman.jabsiri.co.kr
이문서는 LibreOffice 의 Templet 을 이용해 제작 되었습니다 .