A Simple Discrete-Event Simulation: Part 25

The solution is that there is no solution. The simplest thing to do is to ensure that the values are updated by hand whenever they need to be drawn. I’ve included a method called assignDisplayValues to the arrivals component. It should be called just before the drawBasicFunction. This feels wasteful and kludgy, but it seems like the most straightforward thing to do. Other solutions (like burying values in arrays) impose overheads of their own, so I figure it would be best to just be honest about what’s happening. In the long run this will be the most clear solution for the programmer.

I’m surprised that I hadn’t really appreciated this aspect of JavaScript until now, but perhaps I shouldn’t be. Every tool comes with a large number of features you simply won’t see until you do that first thing that forces you to. In the meantime I understand why this limitation is part of the language, but I also understand why people probably find it to be annoying (a word I seem to be using a lot recently…).

This entry was posted in Simulation and tagged , . Bookmark the permalink.

Leave a Reply