Breaking dependencies when you can't make changes to other files?

Posted by codemuncher on Stack Overflow See other posts from Stack Overflow or by codemuncher
Published on 2010-05-11T18:45:58Z Indexed on 2010/05/11 18:54 UTC
Read the original article Hit count: 234

Filed under:
|
|

I'm doing some stealth agile development on a project. The lead programmer sees unit testing, refactoring, etc as a waste of resources and there is no way to convince him otherwise. His philosophy is "If it ain't broke don't fix it" and I understand his point of view. He's been working on the project for over a decade and knows the code inside and out. I'm not looking to debate development practices.

I'm new to the project and I've been tasked with adding a new feature. I've worked on legacy projects before and used agile development practices with good result but those teams were more receptive to the idea and weren't afraid of making changes to code.

I've been told I can use whatever development methodology I want but I have to limit my changes to only those necessary to add the feature. I'm using tdd for the new classes I'm writing but I keep running into road blocks caused by the liberal use of global variables and the high coupling in the classes I need to interact with. Normally I'd start extracting interfaces for these classes and make their dependence on the global variables explicit by injecting them as constructor arguments or public properties.

I could argue that the changes are necessary but considering the lead never had to make them I doubt he would see it my way. What techniques can I use to break these dependencies without ruffling the lead developer's feathers?

I've made some headway using:

  • Extract Interface (for the new classes I'm creating)
  • Extend and override the wayward classes with test stubs. (luckily most methods are public virtual)

But these two can only get me so far.

© Stack Overflow or respective owner

Related posts about unit-testing

Related posts about dependencies