Unit 4 Object-Oriented Design Patterns NameStudent Number CAI XIANGHT082182A KYAW THU LINHT082238Y LI PENGFEIHT082220L NAUNG NAUNG LATTHT082195L PLATHOTTAM.

Slides:



Advertisements
Similar presentations
Welcome to. Who am I? A better way to code Design Patterns ???  What are design patterns?  How many are there?  How do I use them?  When do I use.
Advertisements

OOP Design Patterns Chapters Design Patterns The main idea behind design patterns is to extract the high level interactions between objects and.
DESIGN PATTERNS OZGUR RAHMI DONMEZ.
SWE 4743 Strategy Patterns Richard Gesick. CSE Strategy Pattern the strategy pattern (also known as the policy pattern) is a software design.
 Consists of Creational patterns  Each generator pattern has a Client, Product, and Generator.  The Generator needs at least one operation that creates.
. Plab – Tirgul 12 Design Patterns. Design Patterns u The De-Facto Book on Design Patterns:
BehavioralCmpE196G1 Behavioral Patterns Chain of Responsibility (requests through a chain of candidates) Command (encapsulates a request) Interpreter (grammar.
Design Patterns CS is not simply about programming
Design Patterns Based on Design Patterns. Elements of Reusable Object-Oriented Software. by E.Gamma, R. Helm, R. Johnson,J. Vlissides.
Design Patterns Module Name - Object Oriented Modeling By Archana Munnangi S R Kumar Utkarsh Batwal ( ) ( ) ( )
ECE 355 Design Patterns Tutorial Part 2 (based on slides by Ali Razavi) Presented by Igor Ivković
PRESENTED BY SANGEETA MEHTA EECS810 UNIVERSITY OF KANSAS OCTOBER 2008 Design Patterns.
Design Patterns academy.zariba.com 1. Lecture Content 1.What are Design Patterns? 2.Creational 3.Structural 4.Behavioral 5.Architectural 6.Design Patterns.
1 An introduction to design patterns Based on material produced by John Vlissides and Douglas C. Schmidt.
Creational Patterns Making Objects The Smart Way Brent Ramerth Abstract Factory, Builder.
BY VEDASHREE GOVINDA GOWDA
BDP Behavioral Pattern. BDP-2 Behavioral Patters Concerned with algorithms & assignment of responsibilities Patterns of Communication between Objects.
Design Patterns.
Software Design Refinement Using Design Patterns Instructor: Dr. Hany H. Ammar Dept. of Computer Science and Electrical Engineering, WVU.
02 - Behavioral Design Patterns – 2 Moshe Fresko Bar-Ilan University תשס"ח 2008.
05 - Patterns Intro.CSC4071 Design Patterns Designing good and reusable OO software is hard. –Mix of specific + general –Impossible to get it right the.
Case Studies on Design Patterns Design Refinements Examples.
An Introduction to Design Patterns. Introduction Promote reuse. Use the experiences of software developers. A shared library/lingo used by developers.
CSSE 374: 3½ Gang of Four Design Patterns These slides derived from Steve Chenoweth, Shawn Bohner, Curt Clifton, and others involved in delivering 374.
Behavioral Design Patterns Morteza Yousefi University Of Science & Technology Of Mazandaran 1of 27Behavioral Design Patterns.
Design Patterns CSCI 5801: Software Engineering. Design Patterns.
Strategy Design Patterns CS 590L - Sushil Puradkar.
ECE450 - Software Engineering II1 ECE450 – Software Engineering II Today: Design Patterns IX Interpreter, Mediator, Template Method recap.
Software Design Patterns (1) Introduction. patterns do … & do not … Patterns do... provide common vocabulary provide “shorthand” for effectively communicating.
Design Patterns Façade, Singleton, and Factory Methods Team Good Vibrations (1)
CS 210 Adapter Pattern October 19 th, Adapters in real life Page 236 – Head First Design Patterns.
ECE450S – Software Engineering II
Design Patterns CSIS 3701: Advanced Object Oriented Programming.
ECE450 - Software Engineering II1 ECE450 – Software Engineering II Today: Design Patterns VIII Chain of Responsibility, Strategy, State.
Behavioural Design Patterns Quote du jour: ECE450S – Software Engineering II I have not failed. I've just found 10,000 ways that won't work. - Thomas Edison.
Linzhang Wang Dept. of Computer Sci&Tech, Nanjing University The Strategy Pattern.
OO Methodology Elaboration Iteration 2 - Design Patterns -
Behavioral Patterns CSE301 University of Sunderland Harry R Erwin, PhD.
CS 210 Final Review November 28, CS 210 Adapter Pattern.
Behavioral Patterns1 Nour El Kadri SEG 3202 Software Design and Architecture Notes based on U of T Design Patterns class.
BEHAVIORAL PATTERNS 13-Sep-2012 Presenters Sanjeeb Kumar Nanda & Shankar Gogada.
Pattern Bridge. Definition Bridge is the structural pattern that separates abstraction from the implementation so that both of them can be changed independently.
Advanced Object-oriented Design Patterns Creational Design Patterns.
The Strategy Pattern (Behavioral) ©SoftMoore ConsultingSlide 1.
Example to motivate discussion We have two lists (of menu items) one implemented using ArrayList and another using Arrays. How does one work with these.
CS 210 Proxy Pattern Nov 16 th, RMI – A quick review A simple, easy to understand tutorial is located here:
Chapter 8 Object Design Reuse and Patterns. More Patterns Abstract Factory: Provide manufacturer independence Builder: Hide a complex creation process.
CS 5150 Software Engineering Lecture 16 Program Design 3.
Reference – Object Oriented Software Development Using Java - Jia COP 3331 Object Oriented Analysis and Design Chapter 10 – Patterns Jean Muhammad.
Five Minute Design Patterns Doug Marttila Forest and the Trees May 30, 2009 Template Factory Singleton Iterator Adapter Façade Observer Command Strategy.
An object's behavior depends on its current state. Operations have large, multipart conditional statements that depend on the object's state.
Design Problem & Solution By Team 7 PT. Summary of Problems and Solutions Design Problem Candidate Patterns Motivation of Selection Structure of the Pattern.
Design Patterns Creational Patterns. Abstract the instantiation process Help make the system independent of how its objects are created, composed and.
Overview of Behavioral Patterns ©SoftMoore ConsultingSlide 1.
CLASSIFICATION OF DESIGN PATTERNS Hladchuk Maksym.
Design Patterns: MORE Examples
Abstract Factory Pattern
Strategy Design Pattern
Chapter 10 Design Patterns.
MPCS – Advanced java Programming
Factory Patterns 1.
Introduction to Design Patterns
Design Patterns with C# (and Food!)
object oriented Principles of software design
Abstract Factory Pattern
Presented by Igor Ivković
Ms Munawar Khatoon IV Year I Sem Computer Science Engineering
Informatics 122 Software Design II
Design by Abstraction (Continuation) CS 3331 Spring 2005
Presented by Igor Ivković
Presentation transcript:

Unit 4 Object-Oriented Design Patterns NameStudent Number CAI XIANGHT082182A KYAW THU LINHT082238Y LI PENGFEIHT082220L NAUNG NAUNG LATTHT082195L PLATHOTTAM LINU THANKAMHT082207Y Team S06

VMCS - Existing Model

VMCS - Existing Model (cont.)‏

VMCS – Problems of Existing Model Tight Coupling Creating an object by specifying the class explicitly Dependent on specific operations ChangeGiver, CoinReceiver and DispenserController depends on MachineryController; MachineryConroller depends SimulatorControlerPanel; Makes system modulization impossible. Severely violates DIP. Makes the system unstable.

VMCS – High level view of new design Keep the current division of subsystems. Keep the reference from functional systems to Store Management System. Reduce or remove the reference between functional systems. Reduce direct reference to concrete classes. Improve the stability and extensibility.

VMCS – High level view of new design

VMCS – Issue 1 The process of store data are bind to Property file. It’s difficult to introduce other data resource, such as CSV file, or database, into the current design. Candidate Patterns Factory Pattern – Factory Method is a creational pattern. This pattern helps to model an interface for creating an object which at creation time can let its subclasses decide which class to instantiate. Abstract Factory – This pattern is one level of abstraction higher than factory pattern. This means that the abstract factory returns the factory of classes

VMCS – Solution on Issue 1 Solution – Factory Method Abstract Factory is preferred: It provides a consistent way of data resource solution for both Cash and Drink store This pattern helps to model an interface for creating an object which at creation time can let its subclasses decide which class to instantiate. ParticipantVMCS ClassDescription AbstractFactoryDataLoaderFactory Newly defined interface of producing loader objects ConcreteFactory DataLoaderPropertyFactory DataLoaderCSVFactory Newly defined class of producing loader objects with data in properties file AbstractProduct CashDataLoader DrinkDataLoader Newly defined interfaces which specifies the operations loader object need provider Product CashPropertyLoader DrinkPropertyLoader CashCSVLoader DrinkCSVLoader Loader objects. ClientStoreControllerClient

VMCS – Solution on Issue 1 (cont.)‏

VMCS –Issue 2 The current design UI design is very complex. It is very difficult to extend. Want to decouple the process of building a complex object from the parts that make up the object. Candidate Patterns Builder – Separate the construction of a complex object from its representation so that the same construction process can create different representations. Template Method – Define the skeleton of an algorithm in an operation, deferring some steps to subclasses. Template Method les subclasses redefine certain steps of an algorithm without changing the algorithm’s structure

VMCS – Solution on Issue 2 Builder pattern is favored: Easy to change UI based on the customer requirement. Maintainability. E.g. Changing ReceivingBox’s design will not affect DrinkSelectionBox. Isolate code for construction and representation. Solution – State Pattern

VMCS – Solution on Issue 2 (cont.)‏ Builder (CustomerPanelBuilder)‏ Specifies an abstract interface for creating part of CustomerPanel object. ConcreteBuilder (DefaultCustomerPanelBuilder)‏ Constructs and assembles parts of the product by implementing the Builder interface. Director (TransactionController)‏ Constructs an object using the Builder interface. Product (CustomerPanel)‏ Represents the related object under one construciton. buildCustomerPanel builds the Panel’s internal representation and defines the process by which it’s assembled.

VMCS – Solution on Issue 2 (cont.)‏

VMCS –Issue 3 Flexibility of payment mode Extensibility of payment mode to Cash card or nets instead of inserting coins. The flexibility to add on features is possible with the current design. Candidate Patterns Command Pattern – an object is used to represent and encapsulate all the information needed to call a method at a later time. This information includes the method name, the object that owns the method and values for the method parameters. Strategy Pattern – define a family of algorithms encapsulate each one, and make them interchangeable. Strategy lets the algorithm very independently from clients that use it.

VMCS – Solution on Issue 3 Strategy pattern is favored: Encapsulate various algorithms to do more or less the same thing. Cash card,Nets,Coins algorithms can be created. Reduce multiple conditional statements. Solution – Strategy Pattern

VMCS – Solution on Issue 3 (cont.)‏ Strategy (MoneyReceiver)‏ Declares an interface common to all supported algorithms. Context uses this interface to call the algorithm defined by a ConcreteStrategy. ConcreteStrategy (CoinReceiver, CashCardReceiver)‏ implements the algorithm using the Strategy interface. Context (TransactionController)‏ is configured with a ConcreteStrategy object.maintains a reference to a strategy object.may define an interface that lets Strategy access its data.

VMCS – Solution on Issue 3 (cont.)‏

VMCS –Issue 4 Coordinate the activity of receiving coin, dispensing drink, giving change and terminating transaction. Reduce the coupling between TransactionController and CoinReceiver / DispenserController / ChangeGiver Candidate Patterns Command – an object is used to represent and encapsulate all the information needed to call a method at a later time. This information includes the method name, the object that owns the method and values for the method parameters. State Pattern – represent the state of an object.This is a clean way for an object to partially change its type at runtime

VMCS – Solution on Issue 4 Solution – State Pattern State pattern is favored: It integrates the behavior of receiving coins, selecting and dispensing drinks across various situation. It simplifies the program by removing all the if-else or switch statement, and organizing them into state

VMCS – Solution on Issue 4 (cont.) Let’s treat the customer functions as a machine. Customers can take four actions: Select a drink Input coins Terminate And, the machine responds to user panel: Output – change coins, purchased drink Messages – invalid coin, drink out of stock, etc Response – total inserted coin, etc Now we build a conceptual machine.

VMCS – Solution on Issue 4 (cont.) What are the machine’s states? Waiting for selecting drink Waiting for inputting coin In maintenance. Who is the context? TransactionController For the ease of flow control, the transaction related information is wrapped inside a Transaction class.

VMCS – Solution on Issue 4 (cont.)

State Diagram

VMCS – Solution on Issue 4 (cont.)

VMCS – Issue 5 Update the panels with the real time store information change. E.g. update drink and coin store change on maintenance and machinery panels after transaction is completed; update customer panels when maintainer change drink price, etc. Avoid dependency on specific class / operations Achieve functional extensibility of the system Candidate Patterns Mediator – deals with the complexity which comes in the coding when number of classes increase. Objects no longer communicate directly with each other, but instead communicate through the mediator. Observer – the subject, maintains a list of its dependents, called observers, and notifies them automatically of any state changes, usually by calling one of their methods. It is mainly used to implement distributed event handling systems.

VMCS – Solution on Issue 5 Let MachineryController, MaintenanceController and TransactionController implement ‘Observer’ Let StoreController implements observerable. When changes occur in store, the controller will be notified and act accordingly. Solution – Observer Pattern Observer pattern is preferred than Mediator: It decouples the relationship between store management and controllers. It provides easier functional extensibility.

VMCS – Solution on Issue 5 (cont.)