Components as data storage

Okay, this is a bit of a pointless question, but it’s still playing on my mind.

I’m making an interface a bit like reaktor (custom control widgets laid out on a panel). The user can add any number of Control widgets to a page on a tabbed control panel.

Obviously, the Control widgets contain the settings required to operate, but having worked quite a bit with the whole VST plugin ‘filter / editor’ way of working, i feel it may be safer to store the data outside of the Components (e.g. for the time where they’re not actually being displayed). I’m actually only making this as a standalone app for uni, but it’s always nice to have a portable framework that you can use elsewhere.

My question then is, is it a bad idea to keep the data stored in the Component objects (when they’re not being used on the screen)? Or should the data just be stored elsewhere in a similar structure and referenced in the components?

I’m about to change the design of it so that the data structures are JUST for the data, and the control components (panel, page, control) each hold a reference to a data object. Before I do all this though, I thought I’d ask to see if someone says it’s not worth the effort.

[Having written this post I sort of feel like I’ve answered my own question, and I’m going to do it anyway… but it’s worth asking all the same]

Well, conventional wisdom says there should be a separation between display and data, but if your GUI is complicated it can lead to event propagation hell.

A middle ground is to make a singleton datamanager class and have all your componenets hard wired to it. Data goes to one place, but no cascading event callbacks or pointers being passed all over the place.

Well if you want to follow MVC, then you would have one class for your data (the model), one class for the display (the view), and one class to respond to user actions by making changes in the model (the controller). This approach lets you split up your code into three parts that can each be modified with minimal impact to the others.