Chapter 5 Setting Up for Success

Web Development with Clojure, Third Edition — by Dmitri Sotnikov, Scot Brown (31 / 107)

The Pragmatic Programmers
The Pragmatic Programmers

--

👈 What You’ve Lear ned | TOC | Services 👉

Our guestbook concept is working well, but we aren’t getting much value over our original server-rendered version. In fact, you could argue that we’ve added unnecessary complexity. Let’s talk about some of the reasons why the new design provides a better foundation for growth and enhancement.

Users interact with the application via the interface rendered by the browser. Anytime a user performs an action, such as clicking a button or entering data in a field, they’re updating the state of the application. Web applications typically track this state via user sessions. The more features an application has, the more complicated this session state will be. We could manage this state three ways.

The first approach we could take is to manage sessions entirely on the server and reload the page on each request. This approach is only practical when our state rarely changes, as the entire page has to be sent to the browser and rendered to reflect the outcome of a user action.

This problem can be addressed by the second approach: adding code that runs in the browser to dynamically update parts of the page based on user actions. Unfortunately, this approach introduces a new problem: client-side logic now also has to track its own version of the session state. Keeping the state in…

--

--

The Pragmatic Programmers
The Pragmatic Programmers

We create timely, practical books and learning resources on classic and cutting-edge topics to help you practice your craft and accelerate your career.