SlideShare a Scribd company logo
សាកលវ ិទ្យាល័យភូមិន្ទភនំពេញ
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!

More Related Content

What's hot

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
 

What's hot (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
 

Similar to 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
 

Similar to 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
 

Recently uploaded

How to Position Your Globus Data Portal for Success Ten Good Practices
How to Position Your Globus Data Portal for Success Ten Good PracticesHow to Position Your Globus Data Portal for Success Ten Good Practices
How to Position Your Globus Data Portal for Success Ten Good Practices
Globus
 

Recently uploaded (20)

Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
 
Breaking the Code : A Guide to WhatsApp Business API.pdf
Breaking the Code : A Guide to WhatsApp Business API.pdfBreaking the Code : A Guide to WhatsApp Business API.pdf
Breaking the Code : A Guide to WhatsApp Business API.pdf
 
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital TransformationWSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
 
top nidhi software solution freedownload
top nidhi software solution freedownloadtop nidhi software solution freedownload
top nidhi software solution freedownload
 
How Recreation Management Software Can Streamline Your Operations.pptx
How Recreation Management Software Can Streamline Your Operations.pptxHow Recreation Management Software Can Streamline Your Operations.pptx
How Recreation Management Software Can Streamline Your Operations.pptx
 
A Comprehensive Appium Guide for Hybrid App Automation Testing.pdf
A Comprehensive Appium Guide for Hybrid App Automation Testing.pdfA Comprehensive Appium Guide for Hybrid App Automation Testing.pdf
A Comprehensive Appium Guide for Hybrid App Automation Testing.pdf
 
First Steps with Globus Compute Multi-User Endpoints
First Steps with Globus Compute Multi-User EndpointsFirst Steps with Globus Compute Multi-User Endpoints
First Steps with Globus Compute Multi-User Endpoints
 
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
 
Studiovity film pre-production and screenwriting software
Studiovity film pre-production and screenwriting softwareStudiovity film pre-production and screenwriting software
Studiovity film pre-production and screenwriting software
 
Agnieszka Andrzejewska - BIM School Course in Kraków
Agnieszka Andrzejewska - BIM School Course in KrakówAgnieszka Andrzejewska - BIM School Course in Kraków
Agnieszka Andrzejewska - BIM School Course in Kraków
 
How to Position Your Globus Data Portal for Success Ten Good Practices
How to Position Your Globus Data Portal for Success Ten Good PracticesHow to Position Your Globus Data Portal for Success Ten Good Practices
How to Position Your Globus Data Portal for Success Ten Good Practices
 
Globus Connect Server Deep Dive - GlobusWorld 2024
Globus Connect Server Deep Dive - GlobusWorld 2024Globus Connect Server Deep Dive - GlobusWorld 2024
Globus Connect Server Deep Dive - GlobusWorld 2024
 
Using IESVE for Room Loads Analysis - Australia & New Zealand
Using IESVE for Room Loads Analysis - Australia & New ZealandUsing IESVE for Room Loads Analysis - Australia & New Zealand
Using IESVE for Room Loads Analysis - Australia & New Zealand
 
AI/ML Infra Meetup | Perspective on Deep Learning Framework
AI/ML Infra Meetup | Perspective on Deep Learning FrameworkAI/ML Infra Meetup | Perspective on Deep Learning Framework
AI/ML Infra Meetup | Perspective on Deep Learning Framework
 
Abortion ^Clinic ^%[+971588192166''] Abortion Pill Al Ain (?@?) Abortion Pill...
Abortion ^Clinic ^%[+971588192166''] Abortion Pill Al Ain (?@?) Abortion Pill...Abortion ^Clinic ^%[+971588192166''] Abortion Pill Al Ain (?@?) Abortion Pill...
Abortion ^Clinic ^%[+971588192166''] Abortion Pill Al Ain (?@?) Abortion Pill...
 
De mooiste recreatieve routes ontdekken met RouteYou en FME
De mooiste recreatieve routes ontdekken met RouteYou en FMEDe mooiste recreatieve routes ontdekken met RouteYou en FME
De mooiste recreatieve routes ontdekken met RouteYou en FME
 
AI/ML Infra Meetup | ML explainability in Michelangelo
AI/ML Infra Meetup | ML explainability in MichelangeloAI/ML Infra Meetup | ML explainability in Michelangelo
AI/ML Infra Meetup | ML explainability in Michelangelo
 
Vitthal Shirke Microservices Resume Montevideo
Vitthal Shirke Microservices Resume MontevideoVitthal Shirke Microservices Resume Montevideo
Vitthal Shirke Microservices Resume Montevideo
 
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.ILBeyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
 
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoamOpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
 

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.