Upload
jucagi
View
2.559
Download
0
Tags:
Embed Size (px)
DESCRIPTION
Presentación sobte el patrón de diseño Factoria en ActionScript 3.0
Citation preview
10/04/23Juan Carlos Giraldo Cardozo Programación Multimedia
Contenido
10/04/23Juan Carlos Giraldo Cardozo Programación Multimedia
Design Patterns• Describing recurring
solutions to common problems in software design.
• the capabilities and pitfalls of object-oriented programming,
• and describing 23 classic software design patterns.
10/04/23Juan Carlos Giraldo Cardozo Programación Multimedia
23 classic software design patterns.• Creational
patterns▫ Abstract▫ Builder▫ Factory Meth
od▫ Prototype▫ Singleton
• Structural patterns▫ Adapter▫ Bridge▫ Composite▫ Decorator▫ Facade▫ Flyweight▫ Proxy
• Behavioral patterns▫ Chain of responsi
bility▫ Command▫ Interpreter▫ Iterator▫ Mediator▫ Memento▫ Observer▫ State▫ Strategy▫ Template method▫ Visitor
10/04/23Juan Carlos Giraldo Cardozo Programación Multimedia
Creational patterns
•These patterns have to do with class instantiation. ▫class-creation patterns and (use
inheritance effectively)▫object-creational patterns (use delegation)
10/04/23Juan Carlos Giraldo Cardozo Programación Multimedia
Creational patterns•Abstract Factory groups object factories
that have a common theme.•Builder constructs complex objects by
separating construction and representation.
•Factory Method creates objects without specifying the exact class to create.
•Prototype creates objects by cloning an existing object.
•Singleton restricts object creation for a class to only one instance.
10/04/23Juan Carlos Giraldo Cardozo Programación Multimedia
Factory Method
10/04/23Juan Carlos Giraldo Cardozo Programación Multimedia
The factory method pattern
•is an object-oriented design pattern. • it deals with the problem of creating
objects (products) without specifying the exact class of object that will be created.
•defining a separate method for creating the objects
•which subclasses can then override to specify the derived type of product that will be created.
10/04/23Juan Carlos Giraldo Cardozo Programación Multimedia
ActionScript applicationsthat have multiple classespublic class Client{
public function doSomething( ){
var object:Object = new Product( );object.manipulate( );
}}
10/04/23Juan Carlos Giraldo Cardozo Programación Multimedia
dependency between the Client and Product classes•There’s nothing wrong with this code, but
it does create a coupling or dependency between the Client and Product classes.
•Any changes to the Product class in terms of class name changes or change in the number of parameters passed to it will require changes in the Client class as well.
10/04/23Juan Carlos Giraldo Cardozo Programación Multimedia
Model of the Factory Method Pattern
Client Creator Product1 ** 1
uses create
10/04/23Juan Carlos Giraldo Cardozo Programación Multimedia
public class Creator{
public static function simpleFactory(product:String)
{if (product == "p1"){
return new product1( );} else if (product == "p2") {
return new product2( );}
}}
10/04/23Juan Carlos Giraldo Cardozo Programación Multimedia
Classic factory method pattern
10/04/23Juan Carlos Giraldo Cardozo Programación Multimedia
Classic factory method pattern
• Interfaces and not concrete classes•A pure interface does not provide any
implementation for declared methods. •Abstract interfaces can provide default
implementations for methods. •They’re also called abstract classes, and
cannot be instantiated, but can be extended by other classes.
10/04/23Juan Carlos Giraldo Cardozo Programación Multimedia
Singleton pattern• is a design pattern that is used to restrict
instantiation of a class to one object. •This is useful when exactly one object is
needed to coordinate actions across the system.
•Sometimes it is generalized to systems that operate more efficiently when only one or a few objects exist.
• It is also considered an anti-pattern since it is often used as a euphemism for global variable.
10/04/23Juan Carlos Giraldo Cardozo Programación Multimedia
Singleton pattern
10/04/23Juan Carlos Giraldo Cardozo Programación Multimedia