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 ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access