??? 05/23/12 16:07 Read: times |
#187473 - Not afraid of globals, but... Responding to: ???'s previous message |
I'm not afraid of globals, but I am trying to learn more about testing and single responsibility. While trying to get my legacy code into a test fixture, I realized just how incredibly intertwined my "modules" were. It seems that each one depended on intimate knowledge of other modules, which over time turned into an impossible to refactor free-for-all.
Another problem I had in that code base used global arrays to store various properties that shared a common index rather than structs. This was easy to keep track of at first, but over the years as the code grew to have more and more features, it became harder and harder to keep all of the broken up pieces in sync. That's why I started to play with pointers to structures, but am now wondering if it would be good enough to keep track of an index to an array of structures rather than an actual pointer, and pass that index as a parameter to functions. I think that is getting me back away from easily testable code though... Ideas? |