Slide 1

Slide 1 text

Dr. Javier Gonzalez-Sanchez [email protected] www.javiergs.info o ffi ce: 14 -227 CSC 305 Individual Software Design and Development Lecture 15. Decorator Pattern

Slide 2

Slide 2 text

Previously

Slide 3

Slide 3 text

GoF Patterns 3

Slide 4

Slide 4 text

Observer 4

Slide 5

Slide 5 text

Singleton 5

Slide 6

Slide 6 text

Notes on Decorator | Composite

Slide 7

Slide 7 text

Problem 7

Slide 8

Slide 8 text

Inheritance Approach 8

Slide 9

Slide 9 text

Inheritance Approach 9

Slide 10

Slide 10 text

Inheritance Approach 10

Slide 11

Slide 11 text

Composite 11

Slide 12

Slide 12 text

Decorator | Composite 12

Slide 13

Slide 13 text

Decorator vs Inheritance • Both a llow you to ch a nge how a n object beh a ves. • The decor a tor p a ttern a llows you to extend (decor a te) the function a lity of a n object a t runtime. • Inherit a nce a dds beh a vior a t compil a tion time. 13

Slide 14

Slide 14 text

Connecting the Dots

Slide 15

Slide 15 text

Application 15

Slide 16

Slide 16 text

Application | GUI 16 Main JFrame ChartPanel JPanel

Slide 17

Slide 17 text

Application | Data Gathering 17 Main JFrame ChartPanel Thread Genius JPanel

Slide 18

Slide 18 text

Application | Observer 18 Main JFrame ChartPanel Thread <> Board Genius JPanel PropertyChange Listener PropertyChange Support

Slide 19

Slide 19 text

MarkerDecoratorShadow MarkerDecoratorDot MarkerSimple Application | Decorator 19 MarkerDecoratorDot MarkerSimple MarkerSimple

Slide 20

Slide 20 text

ChallengePlotter | Main 20 https://github.com/CSC3100/Patterns

Slide 21

Slide 21 text

ChallengePlotter | Genius | Runnable 21 https://github.com/CSC3100/Patterns

Slide 22

Slide 22 text

ChallengePlotter | Board | Singleton, Observable 22 https://github.com/CSC3100/Patterns

Slide 23

Slide 23 text

ChallengePlotter | ChartPanel | Observer 23 https://github.com/CSC3100/Patterns

Slide 24

Slide 24 text

ChallengePlotter | Marker | Decorator 24 https://github.com/CSC3100/Patterns

Slide 25

Slide 25 text

ChallengePlotter | MarkerDecorator | Decorator 25 https://github.com/CSC3100/Patterns

Slide 26

Slide 26 text

ChallengePlotter | MarkerDecoratorBar | Decorator 26 https://github.com/CSC3100/Patterns

Slide 27

Slide 27 text

ChallengePlotter | MarkerDecoratorDot | Decorator 27 https://github.com/CSC3100/Patterns

Slide 28

Slide 28 text

ChallengePlotter | MarkerSimple | Decorator 28 https://github.com/CSC3100/Patterns

Slide 29

Slide 29 text

Questions 29

Slide 30

Slide 30 text

Lab 11. Decorator

Slide 31

Slide 31 text

Note 31 UML Class Diagram

Slide 32

Slide 32 text

CSC 305 Individual Software Design and Development Javier Gonzalez-Sanchez, Ph.D. [email protected] Summer 2024 Copyright. These slides can only be used as study material for the class CSC305 at Cal Poly. They cannot be distributed or used for another purpose.