Chapter 6. Refactoring with Classes

In the previous chapter, we learned all about classes in CoffeeScript. Classes are a powerful organizational tool. They let us define objects to separate our code conceptually, and provide mechanisms for code sharing and state management to further enhance what we can do with them.

In this chapter, we'll be putting all this knowledge to work. We're returning to our pet shop application, and we'll be reworking most of the code. We will:

  • Use classes to define the basic data structures of our application
  • Use classes to define the display logic of our application
  • Use static properties and methods to keep our code organized
  • Use inheritance to reduce code duplication

The refactoring cycle

When I work on software projects, ...

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.