Managing State and Front-end Development

Get familiar with how crucial state management is to any application's design.

Many decisions concerning program structure in web applications are about how to manage state, which is the data that controls the interactions between the user and the application. Managing state includes both the location of that data itself and the logic that manipulates that state.

The structure of web applications

A main question we’ll deal with is how to structure our web application to manage our state in the best way. The goal is to avoid having multiple sources of truth by preventing duplicate data and writing the same logic on both the client and the server side. We also want to make the program simple to understand and change.

Problems

A consistent problem in web development is that the browser and HTTP server consider each page view’s interaction as stateless. Stateless means that each interaction is entirely self-contained. For the web server, each request has no relation to or memory of previous requests.

This statelessness is quite useful for web servers because the server doesn’t need to keep track of any state. However, for a web user, statelessness is annoying because the web server never remembers anything about them.

Solution

Web applications depend on maintaining your state to remember who you are and what you’re doing, so developers have created different solutions to manage the state of a user’s interaction with a web server.

Since the beginning of the web, a technical solution state management has been cookies. A cookie is a small amount of data, often a random string of characters, generated by the server and managed by the browser. The cookie allows the browser to identify itself, and an application server can use that identification to remember the user’s state for each request.

Create a free account to view this lesson.

By signing up, you agree to Educative's Terms of Service and Privacy Policy