O'Reilly logo

CoffeeScript Application Development by Ian Young

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

Saving our work with memoization

We're going to look at a simple technique we can use to avoid repeating work. This does not take the place of more advanced performance optimization, but it is a nice way to do some common-sense improvement with almost no effort on your part. The general idea, known as memoization, is to store calculated information so that we can quickly look it up later rather than recalculating it. Now that our application is using classes, we are dealing with objects, and objects have state that we can exploit to easily store modest amounts of data.

There are more complicated (and powerful) ways to memoize data, but we're going to keep it simple. When a piece of information is requested, we'll see if it's stored. If so, we return ...

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