Hello
,
I was wondering about the best way to put the data of a unit into a form. I'm looking for an elegant solution (so far unsuccessfully
), which is why I wanted to ask the pros
.
Currently, I pass an object of the Data class to the GUI class as a pointer.
My goal is to completely decouple the GUI class from Logic, so that all calculations etc happen in the unit and the GUI only fetches or returns data.
But my problem still lies with the interface.
What is the best way to pass the data ? What is the best way return data from the GUI to the Unit ? how can I restore old data if on the form "Cancel" is clicked (I can fetch from the database, but maybe there is a better way ?
) ?
In short:
DATA(Unit) --> GUI(Form) -->
Loop begin
User does Something --> GUI returns Data --> DATA(Unit) Handles Data --> Unit brings new Data to GUI
Loop end
DATA(Unit) --> Save Data
Example: Calculator with 2 fields Edit1/Edit2
1. user enters numbers in those fields
2. Gui passes numbers to Data unit
3. Data Unit multiplies the numbers
4. brings back result to GUI
5. GUI Displays Result
Thanks a lot for any suggestion