O'Reilly logo

Clojure Applied by Alex Miller, Ben Vandgrift

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

Living with Change

We’ve examined in detail several tools that Clojure provides for making updates to our application’s state. These tools guard against misadventure by ensuring that changes are valid and appear instantaneous. We can, however, still shoot ourselves in the foot with sloppy thinking.

It’s difficult to demonstrate the complexities of state management in the kind of toy code that festoons documentation, blog posts, and yes, even books like this one. It helps to keep a few guidelines in mind when applying the mechanisms we’ve seen in action.

How and When to Validate

Our shopping.store API contains a piece of redundancy and a little bit of nastiness. In init, we applied the no-negative-values? function to our inventory as a validator ...

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