Cover | Table of Contents
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();
}
}
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 use the Product class, and requires changing code in multiple locations.
Light class implements a method called on() that turns on a light. A client would execute the following code to turn the light on.var light = new Light(); light.on();
Door class, which implements a method called open() that opens the front door.var frontdoor = new Door(); frontdoor.open();
Light and Door), but to particular methods (on() and open()) in those classes as well. This is not a good situation if we want to have a flexible system that allows future expansion.SlidingDoor, and the method in the class that opens the door is called slideOpen()? We have to modify the code in the client to refer to the new receiver class. Avoid getting into situations that require modifying existing code. In addition, this new situation can require modifications in multiple places. For example, if the front door was controlled from two locations, a wall mounted control panel with buttons assigned to each controlled device and a handheld remote control (like a TV remote), changing the receiver class for the front door would require code changes in both control devices. Also, you couldn't reassign the buttons on the control to a different layout, as the control code is hardcoded to each button.David SanbornWell, I did all the pre-production and I did full demos of all the songs and then I took it into the studio and played it for all the guys and then we kind of took that as the template and did the album live very quickly.
illuminateLight(), for example, would do one thing in the Off state and something entirely different in the On state, even though illuminateLight() method is part of both states.void statement is all lowercase.)
Return to ActionScript 3.0 Design Patterns