Polymorphism

Defining boundaries among your system's roles allows for interchangeability among other behaviors with similar method parameters, method name, and return type. These three components of a method are the contracts that proper messaging requires and together are referred to as a signature. As long as the signatures between varied implementations remain the same, the behaviors can be swapped to achieve various results without having to modify much code, if any.

Let's consider two behaviors extracted from Listing 1-2: grayscaleAverage and rgbAverage. These behaviors are responsible for determining the average brightness of the parameterized vector of pixels and returning the calculated value. Whether the value returned possesses three ...

Get AdvancED 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.