i’m just having a think about the method i’ve used for handling data in my program and think that it’s a bit sloppy, and would just like to check for opinions.
my main component (sitting in a dialog window) holds an array of objects. this array is stored there as it is used thruout the program, but there are two ‘page’ components which operate on the data in different ways.
at the moment, each of these subcomponents are created with a pointer to the array, which they use to access the data. however, i’m sure that this is a stupid and naive way of doing things and i’d like to get into the habit of doing things sensibly.
what is recommended? do i put all the code that manipulates the data within the main component, and have some kind of callback system? i’m not entirely sure how i’d implement that kind of thing.
if, for example, a page component wishes to set a value of an object in the array, what would be the best way? at the moment, it simply calls a class member function to perform some operation on the array from the pointer. this just feels like bad practise. should the function that manipulates the data exist within the main component?
actually, obviously it’s best that the data live in its own class to handle all manipulation. (that’s very stupid of me to not do that here)… but how does the page component best tell the data to operate?
i’d greatly appreciate any help on this topic. cheers