Tech Off Post

Single Post Permalink

View Thread: Good way to implement this type of algorithm?
  • User profile image

    Here's how I would approach a design:

    1. Apply the Principle of Seperation of Concerns, don't forget this, no interdependencies. Also you can discover the best design by writing unit tests first, and you should do this everytime, imho.

    2. Find appropriate design patterns

    Perhaps: A class to capture input. A class that examines the input and acts upon it to create 'interval' records or that examines the 'interval' records state and redirects to an appropriate algorithm. Finally, a bare-bones class for interval records - very simple, just the data, easy to serialize...

    Design Patterns to consider: Visitor, Strategy, Builder/Factory. It takes some time to find the best.