Chapter 2. Factory Method Pattern
As experimentation becomes more complex, the need for the cooperation in it of technical elements from outside becomes greater and the modern laboratory tends increasingly to resemble the factory and to employ in its service increasing numbers of purely routine workers.
The medieval university looked backwards; it professed to be a storehouse of old knowledge. The modern university looks forward, and is a factory of new knowledge.
One cannot walk through an assembly factory and not feel that one is in Hell.
What is the Factory Method Pattern?
One of the most common statements in object-oriented programming (OOP) uses the
new
keyword to instantiate objects from
concrete classes. ActionScript applications that have multiple classes can have an
abundance of code that looks like the following:
public class Client { public function doSomething() { var object:Object = new Product(); object.manipulate(); } }
The Client
class creates a new instance of the
Product
class and assigns it to the variable
object
. There’s nothing wrong with this code,
but it does create a coupling or
dependency between the Client
and Product
classes. Simply
put, the Client
class depends on the Product
class to function properly. 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. This situation is exacerbated if multiple clients ...
Get ActionScript 3.0 Design Patterns now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.