Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
CSE564 Lecture 17
Search
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
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
CSC307 Lecture 21
javiergs
PRO
0
64
CSC307 Lecture 17
javiergs
PRO
0
330
CSC305 Lecture 18
javiergs
PRO
0
380
final project
javiergs
PRO
0
120
CSC305 Lecture 18
javiergs
PRO
0
99
CSC307_L17_mqtt.pdf
javiergs
PRO
0
67
UP Lecture 28
javiergs
PRO
0
62
CSC307_L99_TDD.pdf
javiergs
PRO
0
69
CSC307_L99_TDD.pdf
javiergs
PRO
0
64
Other Decks in Programming
See All in Programming
人間の目はかわらない、だからJPEGは30年もつ
yuzneri
12
18k
Claude Code全社展開のためにやったことn選~プラグイン302個・コミッター271人を支えるために~
kenchan
5
1.4k
VibeCodingからAgenticWorkflowへ
starfish719
0
320
仕様書を書く前にハーネスを作る - Agent Native開発は「探索を速く、判定を固く」
gotalab555
4
1.6k
AIが無かった頃の素敵な出会いの話
codmoninc
1
390
【SRE NEXT 2026 Lunch Session】一人目専任SREの立ち上げを加速する ― AIと進めたオンボーディングで2分を0.04秒にした話
pkshadeck
PRO
0
3.5k
PHP初心者セッション2026 〜生成AIでは見えない裏側を知る:今だからLAMPを通して仕組みを学ぶ〜
kashioka
0
860
テーブルをDELETEした
yuzneri
0
140
OpenSpecのproposalにbrainstormingを持たせてみた
tigertora7571
1
210
jsmini JavaScript Engine を作ってみた話
yosuke_furukawa
PRO
0
300
Google Apps Script で Ruby を動かす
kawahara
0
140
20260722_microCMSで考える、AI時代のコンテンツ運用設計
yosh1
0
380
Featured
See All Featured
Designing for humans not robots
tammielis
254
26k
Performance Is Good for Brains [We Love Speed 2024]
tammyeverts
12
1.8k
The AI Search Optimization Roadmap by Aleyda Solis
aleyda
1
6k
From Legacy to Launchpad: Building Startup-Ready Communities
dugsong
0
290
RailsConf 2023
tenderlove
30
1.5k
Color Theory Basics | Prateek | Gurzu
gurzu
0
410
The B2B funnel & how to create a winning content strategy
katarinadahlin
PRO
1
460
Data-driven link building: lessons from a $708K investment (BrightonSEO talk)
szymonslowik
1
1.2k
Measuring Dark Social's Impact On Conversion and Attribution
stephenakadiri
2
250
Raft: Consensus for Rubyists
vanstee
141
7.6k
Hiding What from Whom? A Critical Review of the History of Programming languages for Music
tomoyanonymous
3
1.1k
Design of three-dimensional binary manipulators for pick-and-place task avoiding obstacles (IECON2024)
konakalab
0
530
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.