General solutions to coding problems often take little more time than specific solutions

I am now coding up an Edgeworth Box model, in which two agents will trade goods until they reach an equilibrium distribution. Now, in the Edgeworth Box, there are only two agents, and each of them only has one good to start with.

But there is no need to program those latter two facts into the model: it is pretty much every bit as easy to code a model with N agents and G goods, and let this particular model be a special case where it just so happens that N = 2 and G = 2. It will only add a couple of lines coding to this round to make this code more generalized, while saving me a great deal of work in the future.

1 comment:

  1. In some ways, yes. But I always dread it because I have to write multiple routines to normalize data types, handle errors, and so forth.

    ReplyDelete