Re: Prize and Milestone as mutable state idioms
"Tyler Close" <[email protected]>
| Newsgroups | gmane.comp.lang.e.general |
|---|---|
| Message-ID | <[email protected]> |
There are at least 2 errors in the code I posted yesterday. If you can't find them, the updated code is at: http://waterken.svn.sourceforge.net/viewvc/waterken/server/trunk/waterken/remote/src/org/waterken/syntax/json/ValueWriter.java?view=markup --Tyler On Mon, Jun 30, 2008 at 4:20 PM, Tyler Close <[email protected]> wrote: > Hi all, > > I was recently refactoring the JSON serialization code in the Waterken > Server to make auditing its correctness easier. In doing so, I wrote > two small utility classes, each one to enforce the update pattern the > code was using for one of its variables. For example, I was using a > boolean variable to keep track of whether or not the most recent JSON > value had been fully and successfully output. The update pattern here > was that the variable started out false and then transitioned to > forever being true. Verifying that this property was correctly > implemented previously required examining the full file for mentions > of the boolean variable to check that it was only ever assigned the > value true. The Milestone class encapsulates a boolean variable that > can only be updated in this way. There's a similar story for the Prize > class. I'm thinking both of these classes may be generally useful and > help communicate the programmer's intention for a mutable variable. If > they are, I think I'll upgrade them to being reusable parts of the > ref_send library. So, I'm looking for answers to a few questions: > > 1. Do the Prize and Milestone classes make the JSON serialization code > more reviewable? > 2. Do you suspect these classes would make other algorithms more reviewable? > 3. Is the ref_send library the right place to host a collection of > these utility classes for capability programming idioms? > > See the attached Joe-E source file for the current JSON serialization code. > > --Tyler >