Data objects with boost::tuple

The data object. Every application’s object model has one or more of these things acting as a container for some stateful data, often in the form of record-level data sourced from outside the application. When approached top-down this usually requires gobs of boring code to implement that are redundant, a pain to maintain, and a downright chore to test.

Over time, with the addition of new data members we usually see new getter/setter pairs added, tweaks to print functions, and maybe manual edits to some critical serialization logic. Aside from being risky if there’s not adequate testing infrastructure in place, this is not the best use of your time — you could be writing far more important business and application logic. All in all, maintaining data objects is alot of work for something that should be braindead simple and done auto-magically.

Here’s an approach for providing flexible data objects built on boost::tuple that are geared toward rapid development, ease of use, and extensibility.

Continue reading…