SlideShare uma empresa Scribd logo
1 de 8
សាកលវ ិទ្យាល័យភូមិន្ទភនំពេញ
Royal University of Phnom Penh
OOAD Assigment
សាស្រ្សាា ចារ្យ: ដាន្ វួន្ពេង
Strategy Pattern:
Tool Calculator
Strategy Pattern
Group Member:
1.Mich Kimliang 2. Ty Veasna
3. Chean Sovanara 4. Ny Touvy5.York Panha
Role
 The Strategy pattern involves removing an algorithm from its host class and putting it in a
separate class.
 There may be different algorithms (strategies) that are applicable for a given problem. If the
algorithms are all kept in the host, messy code with lots of conditional statements will result.
 The Strategy pattern enables a client to choose which algorithm to use from a family of
algorithms and gives it a simple way to access it.
 The algorithms can also be expressed independently of the data they are using.
Illustration
 The strategy pattern lets the algorithms vary independently from clients that use them. For
example, while sorting has many (like binary sort, quicksort), the algorithm is independent of how
to objects/elements are compared. So the sorting algorithm can vary/change independent of
compare algorithm. There are situations when this would be a poor choice and another
algorithm, such as Mergesort, would perform better. Even the linear sorts, such as Shellsort, can
perform very well under certain conditions.
 When studying sorting, one learns about the different conditions to consider and how to
optimize the choice of algorithms. This is a strategy that can be captured in the Strategy pattern.
Design
UML Class Diagram
 Participants
The classes and/or objects participating in this pattern are :
 IStrategy (SortStrategy)
declares an interface common to all supported algorithms.
Context uses
this interface to call the algorithm defined by a Strategy.
 Strategy (QuickSort, ShellSort, MergeSort)
implements the algorithm using the IStrategy interface.
 Context (SortedList)
is configured with a Strategy object
maintains a reference to a Strategy object
may define an interface that lets Strategy access its data.
<<Interface>>
IStrategy
+Algorithm()
StrategyB
+Algorithm()
StrategyA
+Algorithm()
Context
+ContextInterface()
Design
UML Object Diagram
<<Interface>>
IStrategy
+doOperation():Integer
OperationAdd
+doOperation():Integer
Context
-strategy:IStrategy
+executeStrategy():Integer
OperationSubstract
+doOperation():Integer
OperationMultiply
+doOperation():Integer
OperationDivided
+doOperation():Integer
Client
Implementation
 We are going to create a IStrategy interface defining a action and concrete Strategy classes
implementing the IStrategy interface. Context is a class which uses a IStrategy.
 The Client will use Context and Strategy objects to demonstrate change in Context behavior
based on Strategy it deploys or uses.
 Step 1: Create an IStrategy interface.
 Step 2: Create concrete classes implementing the same interface.
 OperationAdd.vb
 OperationSubstract.vb
 OperationMultiply.vb
 OperationDivided.vb
 Step 3: Create Context class.
 Step 4: Use the Context to see change in behavior when it changes its Strategy.
Demo Application
ThankYou!

Mais conteúdo relacionado

Mais procurados

Steering Model Selection with Visual Diagnostics: Women in Analytics 2019
Steering Model Selection with Visual Diagnostics: Women in Analytics 2019Steering Model Selection with Visual Diagnostics: Women in Analytics 2019
Steering Model Selection with Visual Diagnostics: Women in Analytics 2019
Rebecca Bilbro
 

Mais procurados (18)

RapidMiner: Learning Schemes In Rapid Miner
RapidMiner:  Learning Schemes In Rapid MinerRapidMiner:  Learning Schemes In Rapid Miner
RapidMiner: Learning Schemes In Rapid Miner
 
Introduction to Machine Learning
Introduction to Machine LearningIntroduction to Machine Learning
Introduction to Machine Learning
 
Data structures Lecture 5
Data structures Lecture 5Data structures Lecture 5
Data structures Lecture 5
 
Machine learning session 7
Machine learning session 7Machine learning session 7
Machine learning session 7
 
Strategy Pattern
Strategy PatternStrategy Pattern
Strategy Pattern
 
Function template
Function templateFunction template
Function template
 
Design patterns
Design patternsDesign patterns
Design patterns
 
Conceptual modeling
Conceptual modelingConceptual modeling
Conceptual modeling
 
supervised learning
supervised learningsupervised learning
supervised learning
 
Steering Model Selection with Visual Diagnostics: Women in Analytics 2019
Steering Model Selection with Visual Diagnostics: Women in Analytics 2019Steering Model Selection with Visual Diagnostics: Women in Analytics 2019
Steering Model Selection with Visual Diagnostics: Women in Analytics 2019
 
Design principle of pattern recognition system and STATISTICAL PATTERN RECOGN...
Design principle of pattern recognition system and STATISTICAL PATTERN RECOGN...Design principle of pattern recognition system and STATISTICAL PATTERN RECOGN...
Design principle of pattern recognition system and STATISTICAL PATTERN RECOGN...
 
Ppt lesson 08
Ppt lesson 08Ppt lesson 08
Ppt lesson 08
 
Textmining Predictive Models
Textmining Predictive ModelsTextmining Predictive Models
Textmining Predictive Models
 
Supervised Machine Learning With Types And Techniques
Supervised Machine Learning With Types And TechniquesSupervised Machine Learning With Types And Techniques
Supervised Machine Learning With Types And Techniques
 
Machine learning basics
Machine learning   basicsMachine learning   basics
Machine learning basics
 
Overview of machine learning
Overview of machine learning Overview of machine learning
Overview of machine learning
 
Ppt lesson 07
Ppt lesson 07Ppt lesson 07
Ppt lesson 07
 
Data Structure and Algorithms –Introduction.pptx
Data Structure and Algorithms –Introduction.pptxData Structure and Algorithms –Introduction.pptx
Data Structure and Algorithms –Introduction.pptx
 

Semelhante a Strategy pattern ooad presentation

Strategy
StrategyStrategy
Strategy
Monjurul Habib
 
Lecture 1 IntroductionToDataStructures_coursematerial_Draft0.01.ppt
Lecture 1 IntroductionToDataStructures_coursematerial_Draft0.01.pptLecture 1 IntroductionToDataStructures_coursematerial_Draft0.01.ppt
Lecture 1 IntroductionToDataStructures_coursematerial_Draft0.01.ppt
iamsallauddin
 

Semelhante a Strategy pattern ooad presentation (20)

Intruction to Algorithms.pptx
Intruction to Algorithms.pptxIntruction to Algorithms.pptx
Intruction to Algorithms.pptx
 
Cuckoo Search: Recent Advances and Applications
Cuckoo Search: Recent Advances and ApplicationsCuckoo Search: Recent Advances and Applications
Cuckoo Search: Recent Advances and Applications
 
Data clustering using map reduce
Data clustering using map reduceData clustering using map reduce
Data clustering using map reduce
 
A Performance Based Transposition algorithm for Frequent Itemsets Generation
A Performance Based Transposition algorithm for Frequent Itemsets GenerationA Performance Based Transposition algorithm for Frequent Itemsets Generation
A Performance Based Transposition algorithm for Frequent Itemsets Generation
 
Strategy
StrategyStrategy
Strategy
 
Data Analysis – Technical learnings
Data Analysis – Technical learningsData Analysis – Technical learnings
Data Analysis – Technical learnings
 
Implementing Merge Sort
Implementing Merge SortImplementing Merge Sort
Implementing Merge Sort
 
Lecture 1 and 2
Lecture 1 and 2Lecture 1 and 2
Lecture 1 and 2
 
An Algorithm of Policy Gradient Reinforcement Learning with a Fuzzy Controlle...
An Algorithm of Policy Gradient Reinforcement Learning with a Fuzzy Controlle...An Algorithm of Policy Gradient Reinforcement Learning with a Fuzzy Controlle...
An Algorithm of Policy Gradient Reinforcement Learning with a Fuzzy Controlle...
 
Chapter 1 Introduction to Data Structures and Algorithms.pdf
Chapter 1 Introduction to Data Structures and Algorithms.pdfChapter 1 Introduction to Data Structures and Algorithms.pdf
Chapter 1 Introduction to Data Structures and Algorithms.pdf
 
Lecture 1 IntroductionToDataStructures_coursematerial_Draft0.01.ppt
Lecture 1 IntroductionToDataStructures_coursematerial_Draft0.01.pptLecture 1 IntroductionToDataStructures_coursematerial_Draft0.01.ppt
Lecture 1 IntroductionToDataStructures_coursematerial_Draft0.01.ppt
 
Supervised learning techniques and applications
Supervised learning techniques and applicationsSupervised learning techniques and applications
Supervised learning techniques and applications
 
Selecting the Right Type of Algorithm for Various Applications - Phdassistance
Selecting the Right Type of Algorithm for Various Applications - PhdassistanceSelecting the Right Type of Algorithm for Various Applications - Phdassistance
Selecting the Right Type of Algorithm for Various Applications - Phdassistance
 
A Novel Methodology to Implement Optimization Algorithms in Machine Learning
A Novel Methodology to Implement Optimization Algorithms in Machine LearningA Novel Methodology to Implement Optimization Algorithms in Machine Learning
A Novel Methodology to Implement Optimization Algorithms in Machine Learning
 
ifip2008albashiri.pdf
ifip2008albashiri.pdfifip2008albashiri.pdf
ifip2008albashiri.pdf
 
class diagram
class diagramclass diagram
class diagram
 
Data structures and algorithms short note (version 14).pd
Data structures and algorithms short note (version 14).pdData structures and algorithms short note (version 14).pd
Data structures and algorithms short note (version 14).pd
 
Adapted Branch-and-Bound Algorithm Using SVM With Model Selection
Adapted Branch-and-Bound Algorithm Using SVM With Model SelectionAdapted Branch-and-Bound Algorithm Using SVM With Model Selection
Adapted Branch-and-Bound Algorithm Using SVM With Model Selection
 
EE-232-LEC-01 Data_structures.pptx
EE-232-LEC-01 Data_structures.pptxEE-232-LEC-01 Data_structures.pptx
EE-232-LEC-01 Data_structures.pptx
 
chapter 5 Objectdesign.ppt
chapter 5 Objectdesign.pptchapter 5 Objectdesign.ppt
chapter 5 Objectdesign.ppt
 

Último

TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
mohitmore19
 
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdfintroduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
VishalKumarJha10
 

Último (20)

A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docx
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview Questions
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial Goals
 
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS LiveVip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
 
Exploring the Best Video Editing App.pdf
Exploring the Best Video Editing App.pdfExploring the Best Video Editing App.pdf
Exploring the Best Video Editing App.pdf
 
10 Trends Likely to Shape Enterprise Technology in 2024
10 Trends Likely to Shape Enterprise Technology in 202410 Trends Likely to Shape Enterprise Technology in 2024
10 Trends Likely to Shape Enterprise Technology in 2024
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
 
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
Direct Style Effect Systems -The Print[A] Example- A Comprehension AidDirect Style Effect Systems -The Print[A] Example- A Comprehension Aid
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTV
 
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdfintroduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Models
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.com
 
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
 
How To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsHow To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.js
 
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) SolutionIntroducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
 

Strategy pattern ooad presentation

  • 1. សាកលវ ិទ្យាល័យភូមិន្ទភនំពេញ Royal University of Phnom Penh OOAD Assigment សាស្រ្សាា ចារ្យ: ដាន្ វួន្ពេង Strategy Pattern: Tool Calculator
  • 2. Strategy Pattern Group Member: 1.Mich Kimliang 2. Ty Veasna 3. Chean Sovanara 4. Ny Touvy5.York Panha
  • 3. Role  The Strategy pattern involves removing an algorithm from its host class and putting it in a separate class.  There may be different algorithms (strategies) that are applicable for a given problem. If the algorithms are all kept in the host, messy code with lots of conditional statements will result.  The Strategy pattern enables a client to choose which algorithm to use from a family of algorithms and gives it a simple way to access it.  The algorithms can also be expressed independently of the data they are using.
  • 4. Illustration  The strategy pattern lets the algorithms vary independently from clients that use them. For example, while sorting has many (like binary sort, quicksort), the algorithm is independent of how to objects/elements are compared. So the sorting algorithm can vary/change independent of compare algorithm. There are situations when this would be a poor choice and another algorithm, such as Mergesort, would perform better. Even the linear sorts, such as Shellsort, can perform very well under certain conditions.  When studying sorting, one learns about the different conditions to consider and how to optimize the choice of algorithms. This is a strategy that can be captured in the Strategy pattern.
  • 5. Design UML Class Diagram  Participants The classes and/or objects participating in this pattern are :  IStrategy (SortStrategy) declares an interface common to all supported algorithms. Context uses this interface to call the algorithm defined by a Strategy.  Strategy (QuickSort, ShellSort, MergeSort) implements the algorithm using the IStrategy interface.  Context (SortedList) is configured with a Strategy object maintains a reference to a Strategy object may define an interface that lets Strategy access its data. <<Interface>> IStrategy +Algorithm() StrategyB +Algorithm() StrategyA +Algorithm() Context +ContextInterface()
  • 7. Implementation  We are going to create a IStrategy interface defining a action and concrete Strategy classes implementing the IStrategy interface. Context is a class which uses a IStrategy.  The Client will use Context and Strategy objects to demonstrate change in Context behavior based on Strategy it deploys or uses.  Step 1: Create an IStrategy interface.  Step 2: Create concrete classes implementing the same interface.  OperationAdd.vb  OperationSubstract.vb  OperationMultiply.vb  OperationDivided.vb  Step 3: Create Context class.  Step 4: Use the Context to see change in behavior when it changes its Strategy.