design patterns -creational patterns wattanapon g suttapak software engineering, school of...

33
DESIGN PATTERNS -CREATIONAL PATTERNS WATTANAPONG SUTTAPAK Software Engineering, School of Information Communication Technology, University of PHAYAO 1

Upload: steven-rich

Post on 21-Jan-2016

213 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: DESIGN PATTERNS -CREATIONAL PATTERNS WATTANAPON G SUTTAPAK Software Engineering, School of Information Communication Technology, University of PHAYAO 1

1

DESIGN PATTERNS-CREATIONAL

PATTERNS

WATTANAPONG SUTTAPAKSoftware Engineering, School of Information Communication Technology,University of PHAYAO

Page 2: DESIGN PATTERNS -CREATIONAL PATTERNS WATTANAPON G SUTTAPAK Software Engineering, School of Information Communication Technology, University of PHAYAO 1

2

จุ�ดประสงค์การเร�ยนร� �

เข้�าใจุร�ปแบบข้องแบบร�ปการออกแบบทั้��ง 5 ประเภทั้

ประย�กต์ใช้�แบบร�ปการออกแบบ Factory ,Abstract Factory, Singleton, Builder, Prototype Pattern ได�

Page 3: DESIGN PATTERNS -CREATIONAL PATTERNS WATTANAPON G SUTTAPAK Software Engineering, School of Information Communication Technology, University of PHAYAO 1

CREATIONAL PATTERNS

• objects creation and hiding the creation logic• no instantiating objects directly• flexible deciding for a given use case

5 patterns 1. Factory2. Abstract factory3. Builder4. Prototype5. Singleton

Page 4: DESIGN PATTERNS -CREATIONAL PATTERNS WATTANAPON G SUTTAPAK Software Engineering, School of Information Communication Technology, University of PHAYAO 1

4

FACTORY PATTERN

• most used in java• create common interface• create object pattern that inherited(is a) from common interface• create instant object that inherited(has a) from create object pattern create new object via instant object(common)

Page 5: DESIGN PATTERNS -CREATIONAL PATTERNS WATTANAPON G SUTTAPAK Software Engineering, School of Information Communication Technology, University of PHAYAO 1

5

FACTORY PATTERN

Page 6: DESIGN PATTERNS -CREATIONAL PATTERNS WATTANAPON G SUTTAPAK Software Engineering, School of Information Communication Technology, University of PHAYAO 1

6

FACTORY PATTERN

Page 7: DESIGN PATTERNS -CREATIONAL PATTERNS WATTANAPON G SUTTAPAK Software Engineering, School of Information Communication Technology, University of PHAYAO 1

7

FACTORY PATTERN

Page 8: DESIGN PATTERNS -CREATIONAL PATTERNS WATTANAPON G SUTTAPAK Software Engineering, School of Information Communication Technology, University of PHAYAO 1

8

FACTORY PATTERN

Page 9: DESIGN PATTERNS -CREATIONAL PATTERNS WATTANAPON G SUTTAPAK Software Engineering, School of Information Communication Technology, University of PHAYAO 1

9

FACTORY PATTERN Output

Inside Circle::draw() method.

Inside Rectangle::draw() method.

Inside Square::draw() method.

Page 10: DESIGN PATTERNS -CREATIONAL PATTERNS WATTANAPON G SUTTAPAK Software Engineering, School of Information Communication Technology, University of PHAYAO 1

10

FACTORY PATTERN

Page 11: DESIGN PATTERNS -CREATIONAL PATTERNS WATTANAPON G SUTTAPAK Software Engineering, School of Information Communication Technology, University of PHAYAO 1

11

FACTORY PATTERN

Page 12: DESIGN PATTERNS -CREATIONAL PATTERNS WATTANAPON G SUTTAPAK Software Engineering, School of Information Communication Technology, University of PHAYAO 1

12

ABSTRACT FACTORY PATTERN Factory of factories

Page 13: DESIGN PATTERNS -CREATIONAL PATTERNS WATTANAPON G SUTTAPAK Software Engineering, School of Information Communication Technology, University of PHAYAO 1

13

ABSTRACT FACTORY PATTERN Factory PatternShapeCircleRectangleSquare

Abstract Factory PatternColorRedBlueBlackAbstractFactoryColorFactoryShapeFactoryFactoryProducerbstractFactoryPatternDemo

Page 14: DESIGN PATTERNS -CREATIONAL PATTERNS WATTANAPON G SUTTAPAK Software Engineering, School of Information Communication Technology, University of PHAYAO 1

14

ABSTRACT FACTORY PATTERN

Page 15: DESIGN PATTERNS -CREATIONAL PATTERNS WATTANAPON G SUTTAPAK Software Engineering, School of Information Communication Technology, University of PHAYAO 1

15

ABSTRACT FACTORY PATTERN

Page 16: DESIGN PATTERNS -CREATIONAL PATTERNS WATTANAPON G SUTTAPAK Software Engineering, School of Information Communication Technology, University of PHAYAO 1

16

ABSTRACT FACTORY PATTERN

Page 17: DESIGN PATTERNS -CREATIONAL PATTERNS WATTANAPON G SUTTAPAK Software Engineering, School of Information Communication Technology, University of PHAYAO 1

17

ABSTRACT FACTORY PATTERN

Page 18: DESIGN PATTERNS -CREATIONAL PATTERNS WATTANAPON G SUTTAPAK Software Engineering, School of Information Communication Technology, University of PHAYAO 1

18

ABSTRACT FACTORY PATTERN

Page 19: DESIGN PATTERNS -CREATIONAL PATTERNS WATTANAPON G SUTTAPAK Software Engineering, School of Information Communication Technology, University of PHAYAO 1

19

ABSTRACT FACTORY PATTERN Output

Page 20: DESIGN PATTERNS -CREATIONAL PATTERNS WATTANAPON G SUTTAPAK Software Engineering, School of Information Communication Technology, University of PHAYAO 1

20

SINGLETON PATTERN

• Simplest design patterns

• Create object only single object

Page 21: DESIGN PATTERNS -CREATIONAL PATTERNS WATTANAPON G SUTTAPAK Software Engineering, School of Information Communication Technology, University of PHAYAO 1

21

SINGLETON PATTERN

Output Hello World

Page 22: DESIGN PATTERNS -CREATIONAL PATTERNS WATTANAPON G SUTTAPAK Software Engineering, School of Information Communication Technology, University of PHAYAO 1

22

BUILDER PATTERN

Build complex object using simple objects

Page 23: DESIGN PATTERNS -CREATIONAL PATTERNS WATTANAPON G SUTTAPAK Software Engineering, School of Information Communication Technology, University of PHAYAO 1

23

BUILDER PATTERN implements

Page 24: DESIGN PATTERNS -CREATIONAL PATTERNS WATTANAPON G SUTTAPAK Software Engineering, School of Information Communication Technology, University of PHAYAO 1

24

BUILDER PATTERN implements

Page 25: DESIGN PATTERNS -CREATIONAL PATTERNS WATTANAPON G SUTTAPAK Software Engineering, School of Information Communication Technology, University of PHAYAO 1

25

BUILDER PATTERN implements

Page 26: DESIGN PATTERNS -CREATIONAL PATTERNS WATTANAPON G SUTTAPAK Software Engineering, School of Information Communication Technology, University of PHAYAO 1

26

BUILDER PATTERN implements

Page 27: DESIGN PATTERNS -CREATIONAL PATTERNS WATTANAPON G SUTTAPAK Software Engineering, School of Information Communication Technology, University of PHAYAO 1

27

BUILDER PATTERN implements

Page 28: DESIGN PATTERNS -CREATIONAL PATTERNS WATTANAPON G SUTTAPAK Software Engineering, School of Information Communication Technology, University of PHAYAO 1

28

BUILDER PATTERN Output

Page 29: DESIGN PATTERNS -CREATIONAL PATTERNS WATTANAPON G SUTTAPAK Software Engineering, School of Information Communication Technology, University of PHAYAO 1

29

PROTOTYPE PATTERN

creating duplicate object while keeping performance

Page 30: DESIGN PATTERNS -CREATIONAL PATTERNS WATTANAPON G SUTTAPAK Software Engineering, School of Information Communication Technology, University of PHAYAO 1

30

PROTOTYPE PATTERN implements

Page 31: DESIGN PATTERNS -CREATIONAL PATTERNS WATTANAPON G SUTTAPAK Software Engineering, School of Information Communication Technology, University of PHAYAO 1

31

PROTOTYPE PATTERN implements

Page 32: DESIGN PATTERNS -CREATIONAL PATTERNS WATTANAPON G SUTTAPAK Software Engineering, School of Information Communication Technology, University of PHAYAO 1

32

PROTOTYPE PATTERN implements

Page 33: DESIGN PATTERNS -CREATIONAL PATTERNS WATTANAPON G SUTTAPAK Software Engineering, School of Information Communication Technology, University of PHAYAO 1

33

PROTOTYPE PATTERN

Output