Hacker News new | ask | show | jobs
by panic 1957 days ago
> I suppose as soon as something becomes too complex, keeping track of all interactions is just too complicated and rerendering the entire world efficiently looks like an easier problem to deal with.

In fact, it can actually be less work, since you're coalescing changes into a single update() call rather than sprinkling them across observer callbacks. Also, if your update function starts running too slowly, you can always make it more precise by keeping track of which states have changed internally to the view. For example, if setting the background color takes a long time for whatever reason, you can do something like this:

    def View.update():
      if self.lightWasTurnedOn != model.lightTurnedOn:
        if model.lightTurnedOn:
          self.backgroundColor = red
        else:
          self.backgroundColor = ibmGray
        self.lightWasTurnedOn = model.lightTurnedOn
Now backgroundColor will only be set if lightTurnedOn actually changed since the last update.