I have a nested data structure, used by a bunch of functions that presume knowledge of its structure, and I wonder how to change a part of the structure in a safe way, preferably in small incremental steps, rather than having my code broken until I update all the functions and tests for the new structure. I believe many of you must have experiences with this, would you care to share some tips?
The data structure is first built incrementally and the collected data is later summarized. Instead of replacing the raw data with their summary, I want to keep both, so I want to wrap the data with a map; i.e. from:
{ <id> [ data...] } ;; later replaced with {<id> summary}
to
{<id> {:data [data...], :summary ...}
I have a number of functions operating on the structure and tests for those functions (with test data that also need to be updated w.r.t. the refactoring).
When I change one of the functions to produce the new data structure (i.e. data wrapped in a map instead of the data itself), everything else breaks. So I fix some tests and another function and get even more failures. This does not feel as a good way to do it as I prefer to have
limited red and am fond of
parallel change for that reason.
Ideally, I would have an automated refactoring or the possibility to wrap the data in some kind of a two-faced proxy that could behave both as a vector (towards the old code) or as a map containing the vector (towards the updated code) [some thing like lenses/cursor?!]. I haven't either so I guess the only option remaining is a well-controlled process of updating the structure and code. Any advice?
Thank you! /Jakub
--
Forget software. Strive to make an impact, deliver a valuable change.
(Vær så snill og hjelp meg med å forbedre norsken min – skriftlig og muntlig. Takk!)
Jakub Holy
Solutions Engineer | +47 966 23 666
Iterate AS |
www.iterate.noThe Lean Software Development Consultancy
-
http://theholyjava.wordpress.com/ -