It's only a reformulation of Ulises comment but I would say: 1) abstract away how the data is accessed 2) introduce change one function at a time by swapping the past accessor with the new accessor (really it is like a getter/setter) 3) if you have final consumer(s) you might need to introduce a datastructure (a map?) stating which id should be accessed with the new implementation of the accessor
Bertrand Le jeudi 22 mai 2014 10:21:30 UTC+2, Ulises a écrit : > > How are you accessing the data? > > I suppose that if you were accessing (maybe you are) the data via helper > functions, that's where most of the refactoring should happen. > > > On 22 May 2014 09:17, Jakub Holy <jakub...@iterate.no <javascript:>>wrote: > >> 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 <http://www.infoq.com/presentations/The-Limited-Red-Society> and am >> fond of parallel >> change<http://theholyjava.wordpress.com/wiki/development/parallel-design-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.no >> The Lean Software Development Consultancy >> - http://theholyjava.wordpress.com/ - >> >> -- >> You received this message because you are subscribed to the Google >> Groups "Clojure" group. >> To post to this group, send email to clo...@googlegroups.com<javascript:> >> Note that posts from new members are moderated - please be patient with >> your first post. >> To unsubscribe from this group, send email to >> clojure+u...@googlegroups.com <javascript:> >> For more options, visit this group at >> http://groups.google.com/group/clojure?hl=en >> --- >> You received this message because you are subscribed to the Google Groups >> "Clojure" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to clojure+u...@googlegroups.com <javascript:>. >> For more options, visit https://groups.google.com/d/optout. >> > > -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups "Clojure" group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.