CSE 331: Reading 4 and Upgrading Apps
Reading 4 asked: sooner or later you will change a program you did not write, whether a person wrote it or a machine did. What do you need besides the code, and can you get it? In groups, we compare the three articles' answers. Naur says you need the theory of the program, the understanding its authors hold, and that no document hands it to you. Winters says you need the ability to change the code safely, and that tests, policies, and practice build that ability over time. Carlini says the agents that wrote a C compiler needed tests that were nearly perfect, and Regehr, who found 34 bugs in that compiler, says there is no chance his fixed version is correct. Then we argue over that fixed version: is it a live program or a dead one, as Naur uses the words?
Then, upgrading apps.
The guestbook's version with a book for each user now saves each
book in a file. The lecture installs it in place of the old
version, which kept one book for every visitor in book.txt,
while visitors go on using the site. During an upgrade, old code
and new code run at the same time: a page loaded before the
upgrade still sends the old version's requests, and the data the
old version wrote is still on disk.
Every case is judged by one rule: a stronger specification breaks no client that relies only on the old one. Hyrum's Law gives the rule's limit: with enough clients, some client relies on more than the specification. A client's requirement is the part of a specification that the client relies on, so the rule can judge one client at a time, and removing a request takes three steps, in order: expand, move the clients, and contract. The file the old version wrote is a client from the past. Migration, converting it to the new version's form, takes a decision, since its messages are signed with typed names, not logins. Last, a version on every request and every file lets a server answer an out-of-date client with an error that says what is wrong, and code that shows the server's error lets a page show it to its visitor. Both have to be there from the first release. Semantic versioning records a person's comparison of two specifications in a release number.