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

Get CoffeeScript Application Development 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.