Hello,
I am having a problem with designing a certain aspect of a program I have written. The aspect I am referring to is storing objects created by the user for later use when the program is reopened. I would simply populate an array with created objects and then archive the array, but unfortunately the way I have designed the program does not allow me to do so. The basic layout of the project is as follows:
1. Program starts: "Welcome"-type Screen with a "new" button
2. User selects "new" button and a window controller (ConfigureWindowController) displays a window with options that the user can configure.
3. A custom object is created once the user clicks "create" inside the configure window (Done in the ConfigureWindowController)
4. This newly made custom object is then passed to an object that is an instance of another class (declared inside the Configure Window Controller), which translates that object with the properties set by the user into the "final product."
I need to be able to store these new objects (the ones configured in the ConfigureWindowController) for later use when the user reopens the project. My idea is to add the objects to an array and then archive the array. But the problem is that I can't create an array anywhere because I'll end up with instances having an array with just one object in them. For example, let's say I put an array in the ConfigureWindowController:
When the user selects create, the object will be added to the array in that specific instance of ConfigureWindowController -- great!. Flash forward to the future and another instance of ConfigureWindowController displays a configure window after the user selects "new" in the welcome window and another instance of ConfigureWindowController is created and added to that specific instance's array. So now I have two instances with two separate arrays and no real way to archive them. There is no way to have a central array that can store every new object that is created and then have that one central array archived like I would have liked to do.
Could someone help me understand how to fix a design flaw like this? I tried following MVC the best that I could, but it clearly ended up crumbling.
Thanks!
I am having a problem with designing a certain aspect of a program I have written. The aspect I am referring to is storing objects created by the user for later use when the program is reopened. I would simply populate an array with created objects and then archive the array, but unfortunately the way I have designed the program does not allow me to do so. The basic layout of the project is as follows:
1. Program starts: "Welcome"-type Screen with a "new" button
2. User selects "new" button and a window controller (ConfigureWindowController) displays a window with options that the user can configure.
3. A custom object is created once the user clicks "create" inside the configure window (Done in the ConfigureWindowController)
4. This newly made custom object is then passed to an object that is an instance of another class (declared inside the Configure Window Controller), which translates that object with the properties set by the user into the "final product."
I need to be able to store these new objects (the ones configured in the ConfigureWindowController) for later use when the user reopens the project. My idea is to add the objects to an array and then archive the array. But the problem is that I can't create an array anywhere because I'll end up with instances having an array with just one object in them. For example, let's say I put an array in the ConfigureWindowController:
When the user selects create, the object will be added to the array in that specific instance of ConfigureWindowController -- great!. Flash forward to the future and another instance of ConfigureWindowController displays a configure window after the user selects "new" in the welcome window and another instance of ConfigureWindowController is created and added to that specific instance's array. So now I have two instances with two separate arrays and no real way to archive them. There is no way to have a central array that can store every new object that is created and then have that one central array archived like I would have liked to do.
Could someone help me understand how to fix a design flaw like this? I tried following MVC the best that I could, but it clearly ended up crumbling.
Thanks!
Last edited: