Skip to main content

CSE 331: Apps with users

The guestbook kept one book, shared by every visitor. Now each user gets a book of their own, so one becomes many. The change starts with a search for every place the guestbook assumes one book: a field and its comment, a path in the server's manual, the page's one list, and the tests. None of them is behind Book's line. The change is to Book's client and to the server's abstract state, and data abstraction cannot keep a client from depending on the abstract state. So the redesign writes the new abstract state first, as two ADTs, Books and Book, and the rest follows from it.

Many then brings questions that one book never raised. Authentication is establishing who sent a request, and the finished program learns it from a header that Tailscale's Serve adds. Authorization is deciding what the user who sent a request may do. A check in the page alone is worked around from the console, so the check goes on the server, inside Book.delete. A User type then turns a coding mistake into a compile-time error. A book exists only for a user who has signed in. The lesson: notice the ones in a program, write them down, and know how to make one into many later.