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
Javier Gonzalez-Sanchez
PRO
September 17, 2020
Programming
0
1.9k
CSE564 Lecture 17
Software Design
More Design Patterns
(202110)
Javier Gonzalez-Sanchez
PRO
September 17, 2020
Tweet
Share
More Decks by Javier Gonzalez-Sanchez
See All by Javier Gonzalez-Sanchez
CSC305 Summer Lecture 02
javiergs
PRO
0
25
CSC305 Summer Lecture 01
javiergs
PRO
0
52
CSC307 Lecture 16
javiergs
PRO
0
150
CSC570 Lecture 13
javiergs
PRO
0
40
CSC307 Lecture 17
javiergs
PRO
0
120
UP Lecture 30
javiergs
PRO
0
86
UP Lecture 25
javiergs
PRO
0
77
CSC486 Lecture 14
javiergs
PRO
0
160
CSC486 Lecture 13
javiergs
PRO
0
120
Other Decks in Programming
See All in Programming
Quality Gates in the Age of Agentic Coding
helmedeiros
PRO
1
110
AIともっと楽するE2Eテスト
myohei
9
3.2k
効率的な開発手段として VRTを活用する
ishkawa
1
180
新しいモバイルアプリ勉強会(仮)について
uetyo
1
190
React 使いじゃなくても知っておきたい教養としての React
oukayuka
12
1.5k
MCPを使ってイベントソーシングのAIコーディングを効率化する / Streamlining Event Sourcing AI Coding with MCP
tomohisa
0
190
Startups on Rails in Past, Present and Future–Irina Nazarova, RailsConf 2025
irinanazarova
0
310
QA x AIエコシステム段階構築作戦
osu
0
210
抽象化という思考のツール - 理解と活用 - / Abstraction-as-a-Tool-for-Thinking
shin1x1
1
860
「次に何を学べばいいか分からない」あなたへ──若手エンジニアのための学習地図
panda_program
3
660
ご注文の差分はこちらですか? 〜 AWS CDK のいろいろな差分検出と安全なデプロイ
konokenj
4
710
はじめてのWeb API体験 ー 飲食店検索アプリを作ろうー
akinko_0915
0
170
Featured
See All Featured
Sharpening the Axe: The Primacy of Toolmaking
bcantrill
44
2.4k
Dealing with People You Can't Stand - Big Design 2015
cassininazir
367
26k
Put a Button on it: Removing Barriers to Going Fast.
kastner
60
3.9k
[Rails World 2023 - Day 1 Closing Keynote] - The Magic of Rails
eileencodes
35
2.5k
Connecting the Dots Between Site Speed, User Experience & Your Business [WebExpo 2025]
tammyeverts
8
390
Building Adaptive Systems
keathley
43
2.7k
Easily Structure & Communicate Ideas using Wireframe
afnizarnur
194
16k
Reflections from 52 weeks, 52 projects
jeffersonlam
351
21k
Creating an realtime collaboration tool: Agile Flush - .NET Oxford
marcduiker
30
2.2k
個人開発の失敗を避けるイケてる考え方 / tips for indie hackers
panda_program
110
19k
Statistics for Hackers
jakevdp
799
220k
Docker and Python
trallard
45
3.5k
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.