Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
CSE564 Lecture 17
Search
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
Javier Gonzalez-Sanchez
PRO
September 17, 2020
Programming
1.9k
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
CSE564 Lecture 17
Software Design
More Design Patterns
(202110)
Javier Gonzalez-Sanchez
PRO
September 17, 2020
More Decks by Javier Gonzalez-Sanchez
See All by Javier Gonzalez-Sanchez
3100_11.pdf
javiergs
PRO
0
53
CSC510 Lecture 16
javiergs
PRO
0
69
CSC510 Lecture 15
javiergs
PRO
0
43
CSC510 Lecture 13
javiergs
PRO
0
27
CSC510 Lecture 14
javiergs
PRO
0
43
CSC310 Lecture 09
javiergs
PRO
0
40
CSC510 Lecture 12
javiergs
PRO
0
64
CSC510 Lecture 11
javiergs
PRO
0
53
CSC310 Lecture 08
javiergs
PRO
0
46
Other Decks in Programming
See All in Programming
Everything will be SERVERLESS — 信じて運用した10年の経験値 / Everything Will be Serverless — Lessons Learned from 10 Years of Operational Experience
seike460
PRO
1
1k
コードレビューのボトルネックを"する側"と"される側"の両面から解消する
yub0n
2
1.6k
コーディング自動化の次へ。人の介入をゼロにするファクトリーとサポートAIによる実践
timakin
3
2.4k
[ハンズオン]AIへの指示だけで「五目並べ」を作ってみよう
satoshi256kbyte
1
370
なぜCTOを降りてFDEを選んだのか?〜なぜプロダクト企業がFDEで顧客の現場に踏み込むのか〜
gonta
1
200
[Rails World 2026] Durable orchestration on Rails: from continuation to workflow
palkan
1
740
AIに “答え“を書かせるのを やめてみた
___akari11
0
120
見えないものを探る要求要件定義に必要な基本的思考 / invisible-requirement-thinking
minodriven
15
8.4k
全ての永続トークンを、生まれる前に消し去りたい!
sylph01
2
560
Kotlinの15年とServer-Side Kotlin
n_takehata
1
140
Next.js: The final boss of Web Performance
guaca
0
100
気持ちぃ〜角丸 Squircle
ryu1013
0
300
Featured
See All Featured
技術選定の審美眼(2025年版) / Understanding the Spiral of Technologies 2025 edition
twada
PRO
120
120k
Save Time (by Creating Custom Rails Generators)
garrettdimon
PRO
33
5.2k
Building a Modern Day E-commerce SEO Strategy
aleyda
45
9.2k
Design of three-dimensional binary manipulators for pick-and-place task avoiding obstacles (IECON2024)
konakalab
0
620
From π to Pie charts
rasagy
1
400
Intergalactic Javascript Robots from Outer Space
tanoku
273
28k
Sam Torres - BigQuery for SEOs
techseoconnect
PRO
0
580
Designing Dashboards & Data Visualisations in Web Apps
destraynor
232
55k
My Coaching Mixtape
mlcsv
0
350
Leveraging LLMs for student feedback in introductory data science courses - posit::conf(2025)
minecr
1
430
Prompt Engineering for Job Search
mfonobong
0
510
Imperfection Machines: The Place of Print at Facebook
scottboms
270
14k
Transcript
jgs CSE 564 Software Design Lecture 17: More Patterns Dr.
Javier Gonzalez-Sanchez
[email protected]
javiergs.engineering.asu.edu | javiergs.com PERALTA 230U Office Hours: By appointment
jgs 564 00010001 GoF Patterns
jgs Factory Wrapper of a constructor One entire object to
be built in a single method call
jgs 564 00010001 Abstract Factory
jgs 564 00010001 Products public interface Shape { void draw();
} public class RoundedRectangle implements Shape { public void draw() { System.out.println("Inside RoundedRectangle/draw() method."); } } public class RoundedSquare implements Shape { public void draw() { System.out.println("Inside RoundedSquare/draw() method."); } } public class Rectangle implements Shape { public void draw() { System.out.println("Inside Rectangle/draw() method."); } }
jgs 564 00010001 Factories public abstract class AbstractFactory { Shape
getShape(String shapeType) ; } public class ShapeFactory extends AbstractFactory { public Shape getShape(String shapeType){ if(shapeType.equalsIgnoreCase("RECTANGLE")){ return new Rectangle(); }else if(shapeType.equalsIgnoreCase("SQUARE")){ return new Square(); } return null; } }
jgs 564 00010001 Factories public class RoundedShapeFactory extends AbstractFactory {
public Shape getShape(String shapeType){ if(shapeType.equalsIgnoreCase("RECTANGLE")){ return new RoundedRectangle(); }else if(shapeType.equalsIgnoreCase("SQUARE")){ return new RoundedSquare(); } return null; } }
jgs 564 00010001 Client public class Client { public static
void main(String[] args) { AbstractFactory shapeFactory = new ShapeFactory(); //get an object of Shape Rectangle Shape shape1 = shapeFactory.getShape("RECTANGLE"); //call draw method of Shape Rectangle shape1.draw(); //get an object of Shape Square Shape shape2 = shapeFactory.getShape("SQUARE"); //call draw method of Shape Square shape2.draw(); ] //get shape factory AbstractFactory shapeFactory1 = new RoundedShapeFactory(); //get an object of Shape Rectangle Shape shape3 = shapeFactory1.getShape("RECTANGLE"); //call draw method of Shape Rectangle shape3.draw(); //get an object of Shape Square Shape shape4 = shapeFactory1.getShape("SQUARE"); //call draw method of Shape Square shape4.draw(); } }
jgs Test Yourselves
jgs 564 00010001 Workspace.java (part 1 / 2)
jgs 564 00010001 User D B A C
jgs 564 00010001 The System D B A C random
jgs Chain of Responsibility Avoid coupling the sender of a
request to its receiver by giving more than one object a chance to handle the request.
jgs 564 00010001 Chain of Responsibility
jgs 564 00010001 Chain of Responsibility // Setup Chain of
Responsibility Handler h1 = new ConcreteHandler2(); Handler h2 = new ConcreteHandler2(); Handler h3 = new ConcreteHandler1(); h1.SetSuccessor(h2); h2.SetSuccessor(h3); // Generate and process request int[] requests = { 2, 5, 14, 22, 18, 3, 27, 20 }; foreach (int i=0; i<requests.lenght; i++) { h1.HandleRequest(request[i]); }
jgs 564 00010001 Handler abstract class Handler { public abstract
void HandleRequest(int request); } class ConcreteHandler1 extends Handler { public override void HandleRequest(int request) { if (request >= 0 && request < 10) { // code here… } else if (successor != null) { successor.HandleRequest(request); } } }
jgs 564 00010001 Handler class ConcreteHandler2 extends Handler { protected
Handler successor; public void setSuccessor(Handler successor) { this.successor = successor; } public override void HandleRequest(int request) { if (request >= 10 && request < 20) { // code here } else if (successor != null) { successor.HandleRequest(request); } } }
jgs 564 00010001 Chain of Responsibility vs Composite vs Decorator
jgs Test Yourselves
jgs 564 00010001 The System D B A C D
B A C Clustering TSP -Nearest Neighbor
jgs 564 00010001 Questions
jgs CSE 564 Software Design Javier Gonzalez-Sanchez, Ph.D.
[email protected]
Fall
2021 Copyright. These slides can only be used as study material for the class CSE564 at ASU. They cannot be distributed or used for another purpose.