O'Reilly logo

Cocoa Design Patterns by Donald A. Yacktman, Erik M. Buck

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

22. Flyweight

The Flyweight pattern minimizes the amount of memory and/or processor overhead required to use objects. The advantages of object-oriented programming are sometimes outweighed by the overhead of using objects particularly when large numbers of object instances are needed at once. The Flyweight pattern enables instance sharing to reduce the number of instances needed while preserving the advantages of using objects. Classes that implement the Flyweight pattern are called “flyweights.”

Motivation

Within Cocoa, flyweights are primarily used for the following three reasons:

• Flyweights encapsulate nonobject data so that the data can be used in contexts where objects are required.

• Flyweights reduce storage requirements when a large ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required