The class trafficControl contains currently both GUI elements and logic for defining the traffic networks. Having both user interface and program logic in the same class will make automated testing difficult, and I need to refactor the code so that the user interface is separated from the logic.
The current structure of the program is:
- main.cpp includes
- trafficControl.h, which includes
- ui_trafficControl.h (this is autogenerated at run-time which causes problems when unit testing)
- tcTrack
- tcTrain
- tcStation
- trafficDataModel
- trafficClock
- main.cpp includes
- trafficControl which includes
- ui_trafficControl.h (autogenerated)
- tcNetworkControl which includes
- tcTrack
- tcTrain
- tcStation
- trafficDataModel
- trafficClock
1. Remove ui references in tcTrack/tcTrain/tcStation/trafficDataModel/TrafficClock
2. Create tcNetworkControl files
3. Initiate tcNetworkControl
3. Move everything except ui elements to tcNetworkControl and update the references to it.
4 Copy reference to station/train/trackListModel to tcNetworkControl and also handleQMLObject
5. Ensure that the program works both when testing and in normal mode.
I also made some changes to the code that imports a file with network commands. Previously, that code opened a file, scanned it for all lines and interpreted them to commands. The new code scans a file, and parses the lines to another method in networkControl. With this change, I'll be able to define the network from other sources, such as test case and user input at runtime.
No comments:
Post a Comment