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
·
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
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_L17_mqtt.pdf
javiergs
PRO
0
29
UP Lecture 28
javiergs
PRO
0
23
CSC307_L99_TDD.pdf
javiergs
PRO
0
32
CSC307_L99_TDD.pdf
javiergs
PRO
0
42
UP Lecture 27
javiergs
PRO
0
25
UP Lecture 26
javiergs
PRO
0
26
CSC305 Lecture 21
javiergs
PRO
0
38
CSC364 Lecture 18
javiergs
PRO
0
59
CSC364 Lecture 17
javiergs
PRO
0
170
Other Decks in Programming
See All in Programming
「なんか〇〇ライブラリで脆弱性あるみたいなんだけど。。。」から始める脆弱性対応 / First Steps in Vulnerability Response
mackey0225
2
130
ふにゃっとしない名前の付け方 〜哲学で茹で上げる、コシのあるソフトウェア設計〜
shimomura
0
120
ついに来た!本格的なマルチクラウド時代の Google Cloud
maroon1st
0
460
Firefoxにコントリビューションして得られた学び
ken7253
2
170
20260514 - build with ai 2026 - build LINE Bot with Gemini CLI
line_developers_tw
PRO
0
450
Surviving Black Friday: 329 billion requests with Falcon!
ioquatix
0
3.2k
横断組織出身のQAEがインプロセスQAEでつまずいたこと・活かせたこと
ty89
0
150
色即是空、空即是色、データサイエンス
kamoneggi
1
130
AI Agent と正しく分析するための環境作り
yoshyum
2
540
今さら聞けないCancellationToken
htkym
0
100
Sans tests, vos agents ne sont pas fiables
nabondance
0
140
なぜあなたのコードには「コシ」がないのか?〜AI時代に問う、最後まで美味しい設計と戦略〜 #phpconkagawa / phpconkagawa2026
shogogg
0
210
Featured
See All Featured
The AI Revolution Will Not Be Monopolized: How open-source beats economies of scale, even for LLMs
inesmontani
PRO
3
3.4k
Navigating Algorithm Shifts & AI Overviews - #SMXNext
aleyda
1
1.2k
YesSQL, Process and Tooling at Scale
rocio
174
15k
The Invisible Side of Design
smashingmag
302
52k
RailsConf 2023
tenderlove
30
1.4k
Odyssey Design
rkendrick25
PRO
2
620
Gemini Prompt Engineering: Practical Techniques for Tangible AI Outcomes
mfonobong
2
400
A Modern Web Designer's Workflow
chriscoyier
698
190k
Exploring anti-patterns in Rails
aemeredith
3
360
The AI Search Optimization Roadmap by Aleyda Solis
aleyda
1
5.8k
Paper Plane
katiecoart
PRO
1
50k
Claude Code どこまでも/ Claude Code Everywhere
nwiizo
65
55k
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.