BILL SANDERS SANDLIGHT PRODUCTIONS BLOOMFIELD, CONNECTICUT Factory Method Design Pattern: ActionScript 3.0 Implementation.

Slides:



Advertisements
Similar presentations
SE-1020 Dr. Mark L. Hornick 1 Inheritance and Polymorphism: Abstract Classes The “not quite” classes.
Advertisements

Chapter 10: Introduction to Inheritance
ITEC200 – Week03 Inheritance and Class Hierarchies.
 Consists of Creational patterns  Each generator pattern has a Client, Product, and Generator.  The Generator needs at least one operation that creates.
Feb Ron McFadyen1 Factory Method Iterator Example : Java collection classes represent an example of the Factory Method design pattern. The.
Fall 2007CS 2251 Inheritance and Class Hierarchies Chapter 3.
June 1, 2000 Object Oriented Programming in Java (95-707) Java Language Basics 1 Lecture 3 Object Oriented Programming in Java Language Basics Classes,
1 Scenario: Audio Clip Imagine that your application played an audio clip Based on user action, a different audio clip may begin playing You want only.
March Ron McFadyen1 Singleton pattern Singleton is designed to restrict instantiation of a class to one (or a few) objects. Useful when exactly.
Chapter 7 - Generalization/Specialization and Inheritance1 Chapter 7 Generalization/Specialization and Inheritance.
Inheritance using Java
Singleton Christopher Chiaverini Software Design & Documentation September 18, 2003.
CS 240 Week 3. List’Em java Grep [-r] directoryName fileSelectionPattern substringSelectionPattern Run Demo java LineCount [-r] directoryName fileSelectionPattern.
Advanced Programming Rabie A. Ramadan 7.
Abstract Factory Design Pattern making abstract things.
Factory Method A Creational Design Pattern. Factory Method Key Features  Defines an interface for creating objects without needing to know each object’s.
Design Pattern. The Observer Pattern The Observer Pattern defines a one-to-many dependency between objects so that when one object changes state, all.
Tech Talk Go4 Factory Patterns Presented By: Matt Wilson.
Abstract Factory Pattern. What Is an Abstract Factory Pattern?  The Abstract Factory pattern is a creative way to expand on the basic Factory pattern.
Inheritance in the Java programming language J. W. Rider.
The Factory Patterns SE-2811 Dr. Mark L. Hornick 1.
1 Creational Design Patterns CSC 335: Object-Oriented Programming and Design.
Mohammed Al-Dhelaan CSci 253 Object Oriented Design Instructor: Brad Taylor 06/02/2009 Factory Method Pattern.
Programming in Java CSCI-2220 Object Oriented Programming.
Define an interface for creating an object, but let subclasses decide which class to instantiate Factory Method Pattern.
The Factory Method Design Pattern Motivation: Class / Type separation – Abstract class serves as type definition and concrete class provides implementation.
CS 4233 Review Feb February Review2 Outline  Previous Business – My.wpi.edu contains all grades to date for course – Review and contact.
Define an interface for creating an object, but let subclasses decide which class to instantiate.
Creational Pattern: Factory Method At times, a framework is needed to standardize the behavior of objects that are used in a range of applications, while.
1 More OO Design Patterns CSC 335: Object-Oriented Programming and Design.
CSE 341, S. Tanimoto Java brief review - 1 Java Brief Review Java’s strengths Object-oriented terminology Inheritance Interfaces An example with inheritance.
CS 590L – Distributed Component Architecture 02/20/2003Uttara Paingankar1 Design Patterns: Factory Method The factory method defines an interface for creating.
ActionScript 3 Using Sound Related Classes by Martin Stanhope The University of Bolton.
FACTORY METHOD. Design Pattern Space Purpose ScopeCreationalStructuralBehavioral ClassFactory MethodAdapterInterpreter Template Method ObjectAbstract.
MIT AITI 2004 – Lecture 13 Abstract Classes and Interfaces.
Lecture 21 - Abstract Classes and Interface. Example Figure –Rectangle –Triangle Figure –Dimensions –Area.
The Factory Method Pattern (Creational) ©SoftMoore ConsultingSlide 1.
The Factory Pattern Sanjay Yadav (ISE ).
Java Programming, Second Edition Chapter Twelve Advanced Inheritance Concepts.
Proxy Pattern defined The Proxy Pattern provides a surrogate or placeholder for another object to control access to it by creating a representative object.
Singleton Pattern Presented By:- Navaneet Kumar ise
CS 210 Proxy Pattern Nov 16 th, RMI – A quick review A simple, easy to understand tutorial is located here:
1 More OO Design Patterns CSC 335: Object-Oriented Programming and Design.
Five Minute Design Patterns Doug Marttila Forest and the Trees May 30, 2009 Template Factory Singleton Iterator Adapter Façade Observer Command Strategy.
Design Patterns. Outline Purpose Purpose Useful Definitions Useful Definitions Pattern Overview Pattern Overview.
Overview of Creational Patterns ©SoftMoore ConsultingSlide 1.
// create some behaviors SwimBehavior csb = new CircularSwimming(); QuackBehavior sqb = new StandardQuacking(); SwimBehavior rsb = new RandomFloating();
CS 350 – Software Design The Decorator Pattern – Chapter 17 In this chapter we expand our e-commerce case study and learn how to use the Decorator Pattern.
Abstract Factory Pattern Jiaxin Wang CSPP Winter 2010.
JAVA ACCESS MODIFIERS. Access Modifiers Access modifiers control which classes may use a feature. A classes features are: - The class itself - Its member.
Factory Method. Intent/Purpose Factory Method is used to deal with a problem of creating objects without specifying the EXACT class of object that we.
Java Interfaces CS 21a: Introduction to Computing I Department of Information Systems and Computer Science Ateneo de Manila University (see Chapter 9 of.
1 Creational Design Patterns CSC 335: Object-Oriented Programming and Design.
1 Lecture Material Design Patterns Visitor Client-Server Factory Singleton.
OOP: Encapsulation &Abstraction
Factory Method Pattern
Inheritance and Polymorphism
Software Design and Architecture
Factory Method Pattern
Figure 8.1 Inheritance: Relationships among timepieces.
null, true, and false are also reserved.
State Design Pattern 1.
Factory Pattern.
Abstract Classes Page
JavaScript Reserved Words
Java Inheritance.
CS 350 – Software Design Singleton – Chapter 21
Chapter 14 Abstract Classes and Interfaces
Chapter 5 Classes.
Figure 8.1 Inheritance: Relationships among timepieces.
Presentation transcript:

BILL SANDERS SANDLIGHT PRODUCTIONS BLOOMFIELD, CONNECTICUT Factory Method Design Pattern: ActionScript 3.0 Implementation

Links and Downloads You will find all materials in.zip folders that you might want to download and open in Flash CS5 or Flex (Flash Builder) to follow along:  Download files from here:  You can also test the applications on the play links  Play links:   All ActionScript 3.0 Design Patterns  

The Factory Method When building a large project, you may not know all of the objects you will use in the future or how objects may change  The Factory Method was designed so that the Client class makes requests from the Factory (Creator), not knowing the details about the product being created. Client Factory Product

Factory Method Class Diagram

Factory Method File Diagram

Request from Client to Factory (Program to interface; not implementation) private var parana:Factory; private function doParana(e:MouseEvent) { parana=new MakeParana(); addChild(parana.factoryMethod()); } Concrete Factory instance Factory interface

Abstract Factory (Creator) package { import flash.display.Sprite; import flash.errors.IllegalOperationError; // ABSTRACT Class) public class Factory { protected var product:Product; // ABSTRACT Method (must be overridden in a subclass) public function factoryMethod():Sprite { throw new IllegalOperationError(“must be overridden"); return null; }

Concrete Factory with Lazy Instantiation package { import flash.display.Sprite; public class MakeParana extends Factory { public override function factoryMethod():Sprite { if(! product) { product=new ParanaProd(); } return product.getObject(); } Lazy instantiation

Abstract Product package { import flash.display.Sprite; import flash.errors.IllegalOperationError; // ABSTRACT Class (should be subclassed and not instantiated) class Product { protected var objNow:Sprite; public function getObject():Sprite { throw new IllegalOperationError(“must be overridden "); return null; }

Concrete Product package { import flash.display.Sprite; public class ParanaProd extends Product { public override function getObject():Sprite { objNow=new Parana(); objNow.x=273.55, objNow.y=276.50; return objNow; } Image in Sprite class