I am working on a Sudoku solver project with GUI which so far contained of a single unit, and that unit contained all the global variables and the template for the TForm class.
Now I want to separate this one unit into 3 parts:
- solving algorithms
- event handling and UI drawing
- providing sample sudokus for testing/debugging
However, moving these to their respective units created a problem - all of them need access to the Form1 global variable,
and there are function calls both directions, e. g. calls in the event handling unit to functions in the sample-provider unit, and the sample-provider unit has calls modifying the Form1 global variable.
I am very inexperienced with object-oriented programming, and figured that maybe if I move only the class template for TForm into a separate unit, and include this unit into the new 3 units I've created, it would solve the problem, but unfortunately that is not the case.
The class template requires function prototypes for all the events that might occur, but I don't want to implement the event handling in this unit for visibility reasons - I only want this unit for the class template and global variables.
What would be a good workaround to this?