By SmartBoard Team. Agenda  Scenario & Writing UML  Discuss with each team’s UML  What if…  BMVV design  Strategy pattern  Applied with BMVV design.

Slides:



Advertisements
Similar presentations
©Ian Sommerville 2000 Software Engineering, 6th edition. Chapter 12Slide 1 Software Design l Objectives To explain how a software design may be represented.
Advertisements

Define a family of algorithms, encapsulate each one, and make them interchangeable. Strategy lets the algorithm vary independently from clients that use.
Message Forwarding Semi-automatic proxy delegation.
Marcelo Santos – OOAD-CDT309, Spring 2008, IDE-MdH 1 Object-Oriented Analysis and Design - CDT309 Period 4, Spring 2008 Open-closed principle.
SWE 4743 Strategy Patterns Richard Gesick. CSE Strategy Pattern the strategy pattern (also known as the policy pattern) is a software design.
Plab – Tirgul 12 Design Patterns
Strategy AKA Policy Dale Willey Ian Price. Overview Definitions Difference between Strategy pattern and strategy Where would you use this? Challenges.
. Plab – Tirgul 12 Design Patterns. Design Patterns u The De-Facto Book on Design Patterns:
7M701 1 Class Diagram advanced concepts. 7M701 2 Characteristics of Object Oriented Design (OOD) objectData and operations (functions) are combined 
Spring 2010CS 2251 Design Patterns. Spring 2010CS 2252 What is a Design Pattern? "a general reusable solution to a commonly occurring problem in software.
Design Patterns Module Name - Object Oriented Modeling By Archana Munnangi S R Kumar Utkarsh Batwal ( ) ( ) ( )
Marcelo Santos – OOAD-CDT309, Spring 2008, IDE-MdH 1 Object-Oriented Analysis and Design - CDT309 Period 4, Spring 2008 Design Patterns: someone has already.
Recursion. Definitions I A recursive definition is a definition in which the thing being defined occurs as part of its own definition Example: A list.
PRESENTED BY SANGEETA MEHTA EECS810 UNIVERSITY OF KANSAS OCTOBER 2008 Design Patterns.
1 An introduction to design patterns Based on material produced by John Vlissides and Douglas C. Schmidt.
Chapter 1: Introduction to Design Patterns. SimUDuck Example.
02 - Behavioral Design Patterns – 2 Moshe Fresko Bar-Ilan University תשס"ח 2008.
1 GoF Template Method (pp ) GoF Strategy (pp ) PH Single User Protection (pp ) Presentation by Julie Betlach 6/08/2009.
Emeka Egbuonye CSPP March 02,2010 The Mediator Pattern.
Case Studies on Design Patterns Design Refinements Examples.
CS 4240: More Design Patterns Readings: Chap. 9. Let’s Recap Some Ideas and Strategies We’ll assume some design-planning is useful up-front Design with.
Tech Talk Go4 Factory Patterns Presented By: Matt Wilson.
CSE 219 Computer Science III Program Design Principles.
Y2 eProjects Session 4 – Advanced Topics. Objectives  Dynamic Models  Design Patterns (Optional)  Software testing (for S4) ACCP i7.1\Sem3_4\eProject\T4.
1 Some initial Design suggestions… Getting started… where to begin? Find out whether your design architecture will work… as soon as possible. If you need.
 How are you going to collaborate?  How are you going to divide up work?  How are you going to make sure that changes work with other people’s code?
Methods and Models Choice of methods for Development of IT related products and systems SVINGSVING Conference held in Gothenburg, Sweden, October 2000.
CS 350 – Software Design The Strategy Pattern – Chapter 9 Changes to software, like other things in life, often focus on the immediate concerns and ignore.
Strategy Design Patterns CS 590L - Sushil Puradkar.
L8 - March 28, 2006copyright Thomas Pole , all rights reserved 1 Lecture 8: Software Asset Management and Text Ch. 5: Software Factories, (Review)
CSC480 Software Engineering Lecture 11 September 30, 2002.
Unit 4 Object-Oriented Design Patterns NameStudent Number CAI XIANGHT082182A KYAW THU LINHT082238Y LI PENGFEIHT082220L NAUNG NAUNG LATTHT082195L PLATHOTTAM.
Behavioral Pattern: Strategy C h a p t e r 5 – P a g e 205 The Open-Closed Principle advocates designing software in such a way that it will absorb new.
ECE450 - Software Engineering II1 ECE450 – Software Engineering II Today: Design Patterns VIII Chain of Responsibility, Strategy, State.
Define an interface for creating an object, but let subclasses decide which class to instantiate Factory Method Pattern.
Define an interface for creating an object, but let subclasses decide which class to instantiate.
Design Patterns Yonglei Tao. Design Patterns  A design pattern describes a recurring design problem, a solution, and the context in which that solution.
Linzhang Wang Dept. of Computer Sci&Tech, Nanjing University The Strategy Pattern.
OO Methodology Elaboration Iteration 2 - Design Patterns -
DESIGN PATTERNS COMMONLY USED PATTERNS What is a design pattern ? Defining certain rules to tackle a particular kind of problem in software development.
Security in Outsourced Association Rule Mining. Agenda  Introduction  Approximate randomized technique  Encryption  Summary and future work.
STRATEGY PATTERN. Design Pattern Space Purpose ScopeCreationalStructuralBehavioral ClassFactory MethodAdapterInterpreter Template Method ObjectAbstract.
Computer Science 340 Software Design & Testing Software Architecture.
Stéphane Ducasse 1 Strategy.
1 Advanced Software Architecture Muhammad Bilal Bashir PhD Scholar (Computer Science) Mohammad Ali Jinnah University.
Deriving State…...and an example of combining behaviour.
The Strategy Pattern (Behavioral) ©SoftMoore ConsultingSlide 1.
Abstract Classes and Interfaces. Let’s say we are working on a video game together… Our job is to independently write two different enemies for the game.
An object's behavior depends on its current state. Operations have large, multipart conditional statements that depend on the object's state.
Recursion. Definitions I A recursive definition is a definition in which the thing being defined occurs as part of its own definition Example: A list.
STRATEGY PATTERN By Michelle Johnson. BACKGROUND Behavioral Pattern Allow you to define a family of algorithms, encapsulate each one, and make them interchangeable.
Csci 490 / Engr 596 Special Topics / Special Projects Software Design and Scala Programming Spring Semester 2010 Lecture Notes.
Strategy: A Behavioral Design Pattern
Design Patterns: Brief Examples
Strategy Design Pattern
Strategy Pattern Jim Fawcett CSE776 – Design Patterns Fall 2014.
Strategy Pattern.
CS 350 – Software Design The Strategy Pattern – Chapter 9
Chapter Nine The Strategy Pattern
Choose Your Own Adventure
Software Engineering Lecture 7 - Design Patterns
CS/ENGRD 2110 Spring 2016 Lecture 5: Local vars; Inside-out rule; constructors
DESIGN PATTERNS : Strategy Pattern
Design pattern Lecture 9.
Strategy and Template Method Patterns, Single User Protection
State Design Pattern Brandon Jacobsen.
Strategy Design Pattern
Software Design Lecture : 28.
Strategy Pattern Jim Fawcett CSE776 – Design Patterns Fall 2014.
Presentation transcript:

By SmartBoard Team

Agenda  Scenario & Writing UML  Discuss with each team’s UML  What if…  BMVV design  Strategy pattern  Applied with BMVV design  More exercise..

Scenario  Act yourself as Car company owner  Car component will consist of Engine Type Fuel used Nitrous (Additional boost)

Scenario (2)  From its components, we can calculate the fuel burn rate. So, it should include method getBurnFuel(double distance). It comes from Engines power + Nitrous power (if used)  Each car can used only One type of engine One type of Fuel One type of Nitrous  You need some program to show fuel burn rate for each car  Car components can be changed in the future.  Every team, please write UML Class diagram to according to the requirement above…

Writing UML ~10-15 min Take your time…

Time’s up….  Let’s see your UML diagram

What if..  More engine type is added  More fuel type is added  More nitrous type is added  Some car can’t use some engine  No more benzene ??  Can you design support this changes?

Let’s record your problem

BMVV Car company design

BMVV Car company design #2 protected double getBurnFuel(double distance) { if(engine.equalsIgnoreCase("1500CC") && fuel.equalsIgnoreCase("Benzene")) { double consume = distance*0.054; consume = consume*18/17; return consume; } else if(engine.equalsIgnoreCase("1500CC") && fuel.equalsIgnoreCase("Diesel")) { ………….. } else if(engine.equalsIgnoreCase("1500CC") && fuel.equalsIgnoreCase("Gasohol")) { ………….. } else if(engine.equalsIgnoreCase("1900CC") && fuel.equalsIgnoreCase("Benzene")) { ……. } ………….. ……. …

Problems occurs when…  If 4500cc engine are added  No more benzene used.  Super Gasohol is invented.  If each case has more conditions…. else if(engine.equalsIgnoreCase(“4500CC”) && fuel.equalsIgnoreCase(“Benzene”)) { } else if(engine.equalsIgnoreCase(“4500CC”) && fuel.equalsIgnoreCase(“Diesel”)) { } else if(engine.equalsIgnoreCase(“4500CC”) && …Another fuel type… ). else if(engine.equalsIgnoreCase(“1500CC”) && fuel.equalsIgnoreCase(“SuperGasohol”)) { …… } else if(engine.equalsIgnoreCase(“4500CC”) && fuel.equalsIgnoreCase(“SuperGasohol”)) { …… } else if(engine.equalsIgnoreCase(“1900CC”) && fuel.equalsIgnoreCase(“SuperGasohol”)) { …… }

Unable to encapsulates data  According to this design, if you company need to outsource your work… Confidential $$$$$

Strategy patterns  Define a family of algorithms, encapsulate, and make them interchangeable. Strategy lets the algorithm vary independently from clients that use it.

Communication between a station and an unite Every message will be encrypted. Thai military communication network

Old cipher machine model Machine Conditions 1.decryptA 2.decryptB 3.decryptC 4.None (RTA,2) SUB 1500 lines Break encapsulation rule

New cipher machine model Machine (RTA, object) SUB decryptB None decryptA Object.decrypt(“RTA”) Alternative subclass Family of algorithms Eliminate conditions A choice of implementations

New cipher machine model  Decrypt A and B can use signature only a string. Object.decrypt(String);  But Decrypt C need more parameters. Object.decrypt(String, int);  So method signature should have two parameters. Object.decrypt(String, int);  Ex. ObjectA.decrypt(“RTA”, Null); ObjectB.decrypt(“RTA”, Null); ObjectC.decrypt(“RTA”, 366); Communication overhead

Consequences  Families of related algorithms.  An alternative to subclassing.  Strategies eliminate conditional statements.  A choice of implementations.  Clients must be aware of different strategies.  Communication overhead between Strategy and Context.  Increased number of objects.

Another example : Sort  Assume that, you need to write a sort program  There’re many kinds of sort..  Strategy is what we group the many algorithms that do the same things and make it interchangeable at run-time Bubble Sort Selection Sort Descending Sort Heap Sort Quick Sort Ascending Sort SortStrategies Input #1 Result #1 Input #2 Result #2 Runtime

Another example : Sort #2 Change the algorithm at runtime

Apply strategy with BMVV design  Indicates the problem.. Hard to maintain Move it to the new class…

Apply strategy with BMVV design  Re-designing Need getBurnFuel() from different factor So as Nitrous

Apply strategy with BMVV design  Overall design If 4500cc engine is added? Engine4500ccBenzeneEngine4500ccDieselEngine4500ccGasohol If no more benzene? Easier when doing the maintenance !!!

Apply strategy with BMVV design  How it works at runtime Jazz is changing its engine It will call BurnFuel(double) according to its engine

An action adventure game

Solutions of exercise

Q/A

References    a/nos2.jpg    on.gif   