I have a main gui class
that should make use of an additional settings gui class
that has some checkboxes and two buttons. One to load settings and one to save the made settings to a file. My question concerns the design of these two classes.
Storing the settings to a file also requires the state of some members from the main gui class
. Loading the settings from a file will use some functions of the main gui class
to update its member variables.
Is there a design pattern that can be used for this?
I first thought of dependency injection but I think I need some sort of reference to the main gui
in my settings gui
.
While creating the settings class
inside my main class
I thought of the following solutions:
- Pass the
main class
as reference (to the constructor of thesettings class
) - Pass only the needed functions and members of the
main class
as reference
I think the first solution should be avoided because it is considered bad pratice to have both classes refereing to each other but correct me if I am wrong. Is the second solution the way to go or can you suggest a better approach/design pattern?
Aucun commentaire:
Enregistrer un commentaire