Hi,
I've a design problem...
Say I have a class Item and a class ItemList. Now I want to display the
items in a listbox, save and load them.
This is a problem because both the listbox and the ItemList contains the
(same) Items.
I came up with two solutions,
1) Don't use an ItemList class, just add the Items to the listbox and
inherit from a listbox to add a save and load methods.
2) Make some kind of sync method that synchronizes the listbox and the
ItemList class. This seems more complex, because ideally the listbox should
be notified when the ItemList changes, which requires the ItemList to know
about the listbox.
This seems like a very common situation, so what do you do ?
Greetings
Thanks in advance.
I've a design problem...
Say I have a class Item and a class ItemList. Now I want to display the
items in a listbox, save and load them.
This is a problem because both the listbox and the ItemList contains the
(same) Items.
I came up with two solutions,
1) Don't use an ItemList class, just add the Items to the listbox and
inherit from a listbox to add a save and load methods.
2) Make some kind of sync method that synchronizes the listbox and the
ItemList class. This seems more complex, because ideally the listbox should
be notified when the ItemList changes, which requires the ItemList to know
about the listbox.
This seems like a very common situation, so what do you do ?
Greetings
Thanks in advance.