Slide 1

Slide 1 text

Dr. Javier Gonzalez-Sanchez [email protected] www.javiergs.info o ffi ce: 14 -227 CSC 307 Introduction to Software Engineering Lecture 10. Patterns

Slide 2

Slide 2 text

Technical Debt 2

Slide 3

Slide 3 text

Previously

Slide 4

Slide 4 text

Relationships 4

Slide 5

Slide 5 text

Standard Solutions

Slide 6

Slide 6 text

De f inition • Design patterns a re solutions to softw a re design problems you f ind a g a in a nd a g a in in re a l-world a pplic a tion development. • P a tterns a re a bout reusable designs a nd inter a ctions between objects. • The 23 G a ng of Four (GoF) patterns a re gener a lly considered the found a tion for a ll other p a tterns (G a mm a , Helm, Johnson, a nd Vlissides). 6

Slide 7

Slide 7 text

GoF Patterns 7

Slide 8

Slide 8 text

Singleton

Slide 9

Slide 9 text

Singleton 9

Slide 10

Slide 10 text

Singleton class Singleton{ private static Singleton _instance; // Constructor is 'protected' protected Singleton() {} public static Singleton getInstance(){ if (_instance == null){ _instance = new Singleton(); } return _instance; } } 10 https://github.com/CSC3100/Patterns

Slide 11

Slide 11 text

Singleton 11 https://github.com/CSC3100/Patterns

Slide 12

Slide 12 text

Warning 12 Do not Abuse of the Singleton You are transforming OOP into Structural Programming!! 🙈

Slide 13

Slide 13 text

Homework 13 Reading https://medium.com/javarevisited/design-patterns-101-hello-singleton-2d3f227c7729

Slide 14

Slide 14 text

Observer

Slide 15

Slide 15 text

Observer 15

Slide 16

Slide 16 text

Classroom | Initial Version 16 https://github.com/CSC3100/Patterns

Slide 17

Slide 17 text

Student | Initial Version 17 https://github.com/CSC3100/Patterns

Slide 18

Slide 18 text

Teacher | Initial Version 18 https://github.com/CSC3100/Patterns

Slide 19

Slide 19 text

Observer 19

Slide 20

Slide 20 text

Observer 20 https://github.com/CSC3100/Patterns

Slide 21

Slide 21 text

Observable 21 https://github.com/CSC3100/Patterns

Slide 22

Slide 22 text

Classroom | New Version 22 https://github.com/CSC3100/Patterns

Slide 23

Slide 23 text

Student | New Version 23 https://github.com/CSC3100/Patterns

Slide 24

Slide 24 text

Teacher | New Version 24 https://github.com/CSC3100/Patterns

Slide 25

Slide 25 text

Important 25 Do not reinvent the wheel! (Do not make another implementation for classes Observer or Observable -they already exist in libraries!)

Slide 26

Slide 26 text

Important 26 Depreciated java.util.Observer java.util.Observable The implementation of these packages That is NOT about the Observer pattern being depreciated.

Slide 27

Slide 27 text

Important 27 Use java.beans.PropertyChangeListener java.beans.PropertyChangeSupport

Slide 28

Slide 28 text

Classroom | Listener Version 28 https://github.com/CSC3100/Patterns

Slide 29

Slide 29 text

Student | Listener Version 29 https://github.com/CSC3100/Patterns

Slide 30

Slide 30 text

Teacher | Listener Version 30 https://github.com/CSC3100/Patterns

Slide 31

Slide 31 text

Thoughts? 31

Slide 32

Slide 32 text

Homework 32 Reading https://medium.com/swlh/software-design-patterns-why-what-and-an-example-8d4c0934a6ca

Slide 33

Slide 33 text

Questions 33

Slide 34

Slide 34 text

Lab.

Slide 35

Slide 35 text

To Do 35 We need a Tool

Slide 36

Slide 36 text

Tools We need a Tool

Slide 37

Slide 37 text

astah.net 37 https://astah.net/products/students/

Slide 38

Slide 38 text

File | New (projet) 38

Slide 39

Slide 39 text

Create Diagram | Class Diagram 39

Slide 40

Slide 40 text

Tools For the rest of this course Do your Class Diagrams in

Slide 41

Slide 41 text

To Do 41 Create a Class Diagram

Slide 42

Slide 42 text

CSC 307 Introduction to Software Engineering Javier Gonzalez-Sanchez, Ph.D. [email protected] Winter 2026 Copyright. These slides can only be used as study material for the class CSC307 at Cal Poly. They cannot be distributed or used for another purpose.