Agile FAQs
  About   Slides   Home  

 
Managed Chaos
Naresh Jain’s Random Thoughts on Software Development and Adventure Sports
     
`
 
Discovering...
Industrial Logic

Microblog Feed
    Previous Feeds...
    Recent Thoughts

    Recent Comments
    Categories
    Archives
    May 2009
    M T W T F S S
    « Apr   Jun »
     123
    45678910
    11121314151617
    18192021222324
    25262728293031
    RSS Feed
    Add to Technorati Favorites

    Refactoring Legacy Projects: Scaffolding Technique

    If you’ve inherited a Legacy Project (project without any tests) and say you want to enhance an existing feature, where do you start?

    In such situations, I find myself building some form of UI tests (scaffolding). I start off using a record and play back testing tool to record couple of scenarios for the feature I want to enhance. Most often, I would take the recorded tests and covert them into a re-entrant, independent scripts. So that I can execute them over and over again, without needing manual intervention. Basically this would mean, automating the set up and tear down of the application’s external dependencies like data-stores, email servers, etc correctly. This should not take more than a couple of hours to configure. 

    This helps me build the initially safety net to start off. This also gives me a decent understanding of how the feature works. Now I can go inside the code, change something really small and see what impact it has on my tests. Some times I tweak my test to see what impact it has on the feature. Basically I’m using this test as a probe to gain deeper understanding of the feature’s functioning.

    Doing this give me some confidence to jump in and start refactoring the code, so that I can create an inflection point, break dependencies and start writing unit tests around the core of my feature. In couple of hours I should be able to build a solid safety net around my feature using unit tests and/or functional tests.

    At this point, I almost always, go and delete the initial UI test that I had built. This is the reason, I call this approach as the scaffolding technique.

    • Build some initial UI tests to help you get in there, 
    • Make the necessary code/config changes to write direct tests
    • Gradually build a solid safety net around the feature
    • The scaffolding (initial UI tests) did its job, now its time to throw them away
    I demonstrate this technique when we do the Refactoring Fest. We take VQWiki (an open source Java wiki, with Zero tests) and build our scaffolding using Selenium
    • Share/Bookmark
    blog comments powered by Disqus
        Licensed under
    Creative Commons License
    Design by vikivix