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 11. Patterns

Slide 2

Slide 2 text

✅ Dependencies + Architecture ✅ GUI + Multithreading ✅ Object-Oriented Programming Week 06 2 ✅ Clean Code ✅ Object-Oriented Design

Slide 3

Slide 3 text

Running code isn’t enough — design matters This class is about design, not just programming.Being able to compile and run your code is necessary but not sufficient — the focus should be on demonstrating clear design, quality, and adherence to standards.

Slide 4

Slide 4 text

No content

Slide 5

Slide 5 text

GitHubViz 2.0 5 Size control is managed through the alpha value: with zero lines the display is fully transparent, and as the number of lines increases toward the maximum, the color becomes darker. Complexity is represented by color, determined by the total number of conditional or loop statements (if, switch, while, for). When this total exceeds ten, the color is red; when it is greater than five, the color is yellow; otherwise, it is green.

Slide 6

Slide 6 text

UML Cl a ss Di a gr a m

Slide 7

Slide 7 text

Standard Solutions Patterns

Slide 8

Slide 8 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). 8

Slide 9

Slide 9 text

GoF Patterns 9

Slide 10

Slide 10 text

Singleton Pattern

Slide 11

Slide 11 text

Singleton 11

Slide 12

Slide 12 text

Singleton class MainApp { public static void Main(String []a){ Singleton s1 = Singleton.getInstance(); Singleton s2 = Singleton.getInstance(); // Test for same instance if (s1 == s2){ // true - Objects are the same instance } } } 12

Slide 13

Slide 13 text

Singleton class Singleton{ private static Singleton _instance; private Singleton() {} public static Singleton getInstance(){ if (_instance == null){ _instance = new Singleton(); } return _instance; } } 13

Slide 14

Slide 14 text

Observer Patterns

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

Main

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

Problem

Slide 33

Slide 33 text

Problem 33

Slide 34

Slide 34 text

Main 34

Slide 35

Slide 35 text

DataSource 35

Slide 36

Slide 36 text

Panel 36

Slide 37

Slide 37 text

Blackboard 37

Slide 38

Slide 38 text

Questions 38

Slide 39

Slide 39 text

Lab

Slide 40

Slide 40 text

Problem 40

Slide 41

Slide 41 text

CSC 305 Individual Software Design and Development Javier Gonzalez-Sanchez, Ph.D. [email protected] Fall 2025 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.