Saturday, 1 June 2019

StockAnalyzer: Creating a Structure of the Program

I've been able to populate my database with some dummy data and to read it from the database. That's an important step and now, I need to define the overall structure of the program.

Use Cases identifies some scenarios where an user is using the system:

  • User wants to delete all stock records from the database
  • User wants to scan all available files and add the data to the database
  • User wants to scan all files within a specified time range
  • User wants to update the database with the latest results from StockReader

The program will have three different modules:

  • User Interface - Collects the parameters and call methods/functions
  • FileScanner - Select which csv files to scan and determine whether the data in a row contains enough information so that it can be added to the database.
  • DBParser - Build SQL queries and launch them. Database error handling.
Now, I have a rough idea what the program should look like. I have added a couple of user interface widgets to my app. The code is stubbed right now:

I will clean up this form later.
In the "Time Interval to Scan" group box, the user will be able to limit the number of files that shall be loaded into the database.

In the "Directory to Scan" group box, the user will be able to select where the input files are. The text of the button shows the current folder.

The user will be able to clear the database and scan all files that matches the dates in the folder. The algorithm will look like this:

  • List all csv files in the current folder. 
  • For all files that are matching the time interval:
    • Check the headers in order to know how to interpret the data.
    • For all rows in the file: 
      • If the needed data is there for that stock, add the information to the database


I have also created two classes: FileScanner and DBParser. Those are instantiated when the program starts.

In the next blog post, I'll fill the classes and widgets with code.

No comments:

Post a Comment