A Simple Discrete-Event Simulation: Part 33

My main motivation for trying to break the current functionality into M, V, and C layers isn’t about purity of design pattern so much as getting a lot of unnecessary overhead out of the simulation components themselves. They shouldn’t contain any less support functionality than they need, but they shouldn’t include any more, either.

Looking at the output and code for, say, the Queue component, shows that a lot of what’s going on inside the component itself is merely in support of the status display and timing mechanisms. I’m thinking that as much of that as possible should be moved outside of the component object itself.

If all of the display overhead were removed from this code we’d be left with roughly this:

You can see that gets rid of most of the code, and even some of what is left is only there to draw status information in the lower, scrolling text area.

If we want to provide the deleted capability in a more streamlined, external way then we can identify some possible requirements:

  • As much initialization and signalling as possible should be external to the simulation elements.
  • As much state information as possible should be external to the simulation elements.
  • The updating and display of such information should be able to be suppressed (or reactivated) by setting a single, global variable.
  • The external display mechanism needs to maintain a link (pointer) to the simulation element so it knows where to get its data from.
  • The simulation element may need to be able to reference an external display element via a link (pointer) but it would be better if such a link were not necessary.
  • Some displays should be permanent and updatable.
    • Since the display is always visible once defined the simulation element may not need to do anything special to allow the external display mechanism to update itself.
    • If any information in the display mechanism is to “hide” itself on a timed basis then the timing mechanism should be handled entirely within the display mechanism.
  • Some displays should be temporary on a fire-and-forget basis.
    • The internal assignment or initiation of such a display should be kept to one line.
    • If a subsequent update should happen that would change the originally initialized display before it times out, the one-line call should be able to identify the correct external display mechanism and cause it to display the updated information instead.
    • The external display mechanism should incorporate its own timing and hiding capability, if appropriate.
  • Setters and getters need to be created for all internal properties whose values will need to be displayed.
  • Functions that do external update assignments of series of values may need to be defined externally.
  • Some design decisions will reference the fact that (for the time being) the entire display is redrawn after certain classes of events, namely ones that involve processing an event from the future events queue. This idea will have to be revisited when we reincorporate wait..until events and the current events queue.
  • Given the foregoing, it may be possible to detect certain classes of events outside of the simulation elements.
This entry was posted in Simulation and tagged . Bookmark the permalink.

Leave a Reply