Adding Route Type

Components

There are a few components that need to be added or modified when adding a new Route type:

  • Class that can retrieve the information specific to that route (examples are Hill or Facility).
  • EncodedTrack needs to accommodate that extra information when building the Encoded Track.
  • RouteFactory needs to recognize that information as a distinguishing characteristic so it can create the appropriate Route type.
  • Create a new Route Type that extends Appropriate route (DisplayOnlyRoute usually).
  • Override the Window Content (if not other methods) in the new Route Type.

Advantages

  • This is unlikely to disrupt existing functionality for the routes.
  • The Classes that retrieve information about a specific route are hidden behind a simple interface. Doesn't matter whether the data is hard-coded, derived from a database, or calculated on the fly.

Disadvantages

  • EncodedTrack shouldn't be burdened with coming up with a way for the RouteFactory to do its work. This coupling could cause problems.
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License