Archive for February, 2008
Synchronizing Client Models
Wednesday, February 27th, 2008You’re implementing a client-server application. The client is in JavaScript. It contains a model class, Person. The model is backed by a server-side Person model, and a REST controller at /person. Periodically, the client updates the server’s model, but there can be client-side instances that don’t yet exist on the server, such as when a model is first created and the server hasn’t yet gotten the message.
I’ve written this code a few times now, in JavaScript, and in ActionScript. if If you write it the obvious way, you run into an interesting set of race conditions. Here’s the code, and the race conditions, and some ad-hoc solutions. In the next post, I’ll introduce a metaobject pattern, queue ball, that I’ve used to solve these race conditions in a more principled and re-usable fashion.
Read the rest of this entry »
More Monads on the Cheap: Inlined fromMaybe
Tuesday, February 26th, 2008This article is about how to deal with null values. It follows up on this one. It’s intended for code stylists: people who care a lot about the difference between one line of code and two, or keeping control statements and temporary variables to a minimum. (A code stylist is kind of like the dual of a software architect, although one person can be both.) It’s not about code golf – although you might learn some strokes to use on that – but about keeping the structure of your code, even at the expression level, close to the way you think about the problem, if you think like me.
Read the rest of this entry »
Self-Printing JavaScript Literals
Friday, February 15th, 2008Sometimes you need a totally opaque “constant” – a value that isn’t intended to be projected or modified, and whose only purpose is to be completely different from every other value1. For example, Functional uses Functional._ as a placeholder; a comment on John Resig’s blog suggests defining something like Partial.PLACEHOLDER for something similar.
In JavaScript, these are easy to make. Here’s one: {}. And here’s another: {}. Note that these two values are different: the following code2 will print true, then true, then false:
Read the rest of this entry »
Supply/Demand Springs
Thursday, February 7th, 2008Update: This is what I call an entry-level metaphor – it’s a rough sketch of the relation between the concepts, not a productive metaphor that can be used to reason about them beyond this. It doesn’t support analytic microeconomic analysis, and it’s not even consistent at the level of the supply chain. (For example, the unit cost needs to include the component cost, whereas the illustration shows these as complementary; this is because the metaphor leaves out profit.) Nonetheless, I find it a helpful starting point before going more analytic.
Read the rest of this entry »
Knowledge Per Unit Time
Tuesday, February 5th, 2008My friends have been asking me how important I consider experience (again in the context of the election), enough to write the answer down.
Read the rest of this entry »
Two Thoughts on Elections
Tuesday, February 5th, 2008What follow are some notes from talking about the elections and the presidential primaries with my children, and some metaphors that I found helpful in thinking about the topics. They’re not otherwise related to each other, except that they all came up over the last couple of days.
1. Votes are Agents
Read the rest of this entry »
Adding the Easy Piece; or, The Metaphor of the Rock
Saturday, February 2nd, 2008The novice project manager cares about a program’s size. The experienced manager cares when it gets big.
Big programs are, from a developer’s perspective, slow. Slow not to run, but to develop: effortful to maintain, expensive to change. Half the job of a project manager is to keep programs small by keeping their requirements small (and half the job of an architect is to keep them small when the requirements are large); this is about the case when this isn’t enough.
Developing a program is like pushing a rock around a room. (The rock is called “code base”. The room is an irregular shape called “design space”, with “requirements” marked off along the wall.) Big programs are big, heavy rocks. They require more push, to get less far.
Read the rest of this entry »

