A typical workflow needs to be implemented that can be summarized in the following steps: 1) Query the database for the appropriate data, 2) perform analysis on the data (such as aggregation), 3) deliver the data to a front-end system for formatting and display to the user.I can implement the workflow with a linear, in-line code approach easily. My struggle is coming up with the best way to code it for re-usability and scalability. Specifically, I have been exploring the idea of having a class object that encapsulates the entire workflow.The workflow class object would have these methods (and the workflow would be executed in this order):
- getData (build query string, query database, get the results)
- initializeDataModel (initialize a nested-hash-style framework)
- populateDataModel (insert the getData() results into the data model)
- analyzeDataModel (perform analysis on the data in the data model; analysis results are stored in the data model)
- packageDataModel (return the entire data model or a subset of the data model)