Taming Legacy Code Monsters<br />
*<br />Caleb<br />* I’m here to help.<br />
Last year<br />10Reasons yoursoftwareSucks<br />(and the 10 practicesto fix it)<br />
Building teams that engineer better software<br />Development ∙ Team Work ∙ Process<br />
back to…<br />Taming Legacy Code Monsters<br />
back to…<br />Taming Legacy Code Monsters<br />
Definition “Legacy”<br />n. Software that I’m afraid to maintain, extend, or change it actually scares me to touch that co...
What’s the differencebetween an application and<br />
Legacy Monster<br />
Legacy Monster<br />Processor<br />Static Config<br />Static Proxy<br />Processor Settings<br />Data Connections<br />Rule...
Legacy Monster<br />Solution contained over 68 projects.<br />Most of which were notused.<br />No horizontal layers.<br />...
Strategy #1<br />Know your Foe<br />
Strategy #1<br />nDepend<br />
Strategy #1<br />Visual Studio Dependency Graph<br />
Strategy #1<br />Demo<br />Using theVisual Studio Dependency Graph<br />
Strategy #1<br />Demo<br />Pro tip:Look for big blobs& thick linesto concrete types<br />
Strategy #2<br />Create aSafety Net<br />
Source Control+ Test<br />Strategy #2<br />
Strategy #2<br />Source Control+ Test<br />
Strategy #2<br />Source Control<br />
// source<br />// svn / git / tfs  .. <br />// r1.1<br />// r1<br />// r2<br />// r3<br />// trunk<br />// trunk<br />Bran...
Strategy #2<br />Unit TestsIntegration<br />Regression<br />Load Tests<br />Etc…<br />Tests<br />
Isolation and White box Unit Testing for .NET<br />Demo: Safety Net<br />Legacy Monster<br />“Pexautomatically generates t...
what about hard to test code?<br />refactoring testability<br />
privateIList<Bean> goodBeans { get; set;}<br />privateIList<Bean> badBeans { get; set;}<br />publicvoidAddBean(Bean bean){...
1<br />Clearly an arbitrary example<br />Does represent actual production code that I have worked with<br />2<br />3<br />...
publicIList<Bean> GoodBeans{ get; private set;}<br />privateIlist <Bean>badBeans{ get; set;}<br />publicvoidAddBean(Bean b...
What about the UpdateBeans() method?<br />publicvoidUpdateBeans(){<br />BeanData.Update(goodBeans);<br />goodBeans.Clear()...
Code Coverage + Continuous Integration<br />Not a silver bullet<br />still need to make sure that we are testing “the righ...
Code Coverage + Continuous Integration<br />Creates a base line or smoke test to look for<br />Watch trends over magic per...
Code Coverage + Continuous Integration<br />Team City Code Coverage<br />
Code Coverage + Continuous Integration<br />Sonar<br />
Strategy #3<br />
Strategy #3<br />Divide and Conquer <br />(pick your battles)<br />
36<br />Commitment<br />
37<br />                           Raise your hand and repeat after me,<br />Commitment<br />
38<br />                           Raise your hand and repeat after me,<br />Commitment<br />I will not practice bad code....
“Resist Legacy Coupling”<br />
“Resist Legacy Coupling”<br />tight coupling = change anywhereaffects everything<br />Legacy Monster<br />Processor<br />S...
Introduce SOLID principals on new development… gradually improve code over time<br />http://developingux.com/di/<br />
wrap up<br />
Know your Foe <br />wrap up<br />Use a Safety Net<br />Divide and  Conquer<br />
Thank you!<br />Proaction<br />MentorS<br />@calebjenkins<br />http://developingux.com<br />@proactionmentor<br />caleb@pr...
Photo Credits<br />© Michael Cummings - http://dreaminpictures.com<br />http://www.flickr.com/photos/boogeyman13/243266745...
http://www.flickr.com/photos/27620885@N02/2594363003<br />http://www.flickr.com/photos/flyingturtle/3976070342/<br />http:...
Upcoming SlideShare
Loading in...5
×

Taming the Monster Legacy Code Beast

1,861

Published on

Does that legacy code beast stifle your creativity? Do you stay up late at night frightened that someone might touch *that* piece of code? Learn some practical steps on how you can slay the legacy code beasts, divide and conquer, and deliver value to your customers.

Published in: Technology, Sports
0 Comments
2 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
1,861
On Slideshare
0
From Embeds
0
Number of Embeds
4
Actions
Shares
0
Downloads
16
Comments
0
Likes
2
Embeds 0
No embeds

No notes for slide
  • take a minute to have student “read” test and talk out what it’s doing.
  • Build out slide.. Before you click through: take a minute to have student “read” test and talk out what it’s doing.
  • Taming the Monster Legacy Code Beast

    1. 1. Taming Legacy Code Monsters<br />
    2. 2. *<br />Caleb<br />* I’m here to help.<br />
    3. 3.
    4. 4. Last year<br />10Reasons yoursoftwareSucks<br />(and the 10 practicesto fix it)<br />
    5. 5. Building teams that engineer better software<br />Development ∙ Team Work ∙ Process<br />
    6. 6. back to…<br />Taming Legacy Code Monsters<br />
    7. 7. back to…<br />Taming Legacy Code Monsters<br />
    8. 8. Definition “Legacy”<br />n. Software that I’m afraid to maintain, extend, or change it actually scares me to touch that code.<br />
    9. 9. What’s the differencebetween an application and<br />
    10. 10. Legacy Monster<br />
    11. 11. Legacy Monster<br />Processor<br />Static Config<br />Static Proxy<br />Processor Settings<br />Data Connections<br />Rules Configurations<br />Coupling<br />Coupling<br />Coupling<br />Coupling<br />Coupling<br />Rules<br />Data<br />Coupling<br />
    12. 12. Legacy Monster<br />Solution contained over 68 projects.<br />Most of which were notused.<br />No horizontal layers.<br />Required IIS 6 / legacy URL rewriter / 32 bit C Lib / IIS Rules export/import / Database Connections / Proper Configuration X 3<br />To run or test ANY part on a dev box…<br />
    13. 13. Strategy #1<br />Know your Foe<br />
    14. 14. Strategy #1<br />nDepend<br />
    15. 15. Strategy #1<br />Visual Studio Dependency Graph<br />
    16. 16. Strategy #1<br />Demo<br />Using theVisual Studio Dependency Graph<br />
    17. 17. Strategy #1<br />Demo<br />Pro tip:Look for big blobs& thick linesto concrete types<br />
    18. 18. Strategy #2<br />Create aSafety Net<br />
    19. 19. Source Control+ Test<br />Strategy #2<br />
    20. 20. Strategy #2<br />Source Control+ Test<br />
    21. 21. Strategy #2<br />Source Control<br />
    22. 22. // source<br />// svn / git / tfs .. <br />// r1.1<br />// r1<br />// r2<br />// r3<br />// trunk<br />// trunk<br />Branching for FUN!<br />//<br />
    23. 23. Strategy #2<br />Unit TestsIntegration<br />Regression<br />Load Tests<br />Etc…<br />Tests<br />
    24. 24. Isolation and White box Unit Testing for .NET<br />Demo: Safety Net<br />Legacy Monster<br />“Pexautomatically generates test suites with high code coverage.…[and] finds interesting input-output values of your methods, which you can save as a small test suite with high code coverage. Microsoft Pex is a Visual Studio add-in for testing .NET Framework applications.”<br />Processor<br />Static Config<br />Static IProxy<br />Processor Settings<br />Data Connections<br />Rules Configurations<br />http://research.microsoft.com/en-us/projects/pex/<br />Rules<br />Data<br />
    25. 25. what about hard to test code?<br />refactoring testability<br />
    26. 26. privateIList<Bean> goodBeans { get; set;}<br />privateIList<Bean> badBeans { get; set;}<br />publicvoidAddBean(Bean bean){<br /> if(bean.size > 10)<br />goodBeans.Add(bean);<br /> else<br />badBeans.Add(bean);<br />}<br />publicvoidUpdateBeans(){<br />BeanData.Update(goodBeans);<br />goodBeans.Clear();<br />badBeans.Clear();<br />}<br />
    27. 27. 1<br />Clearly an arbitrary example<br />Does represent actual production code that I have worked with<br />2<br />3<br />AddBean(b); AddBean(b), UpdateBeans();<br />Usage scenario is<br />How can we test the AddBean() Logic?<br />
    28. 28. publicIList<Bean> GoodBeans{ get; private set;}<br />privateIlist <Bean>badBeans{ get; set;}<br />publicvoidAddBean(Bean bean){<br />if(bean.size > 10)<br />GoodBeans.Add(bean);<br />else<br />badBeans.Add(bean);<br />}<br />publicvoidUpdateBeans(){<br />BeanData.Update(goodBeans);<br />GoodBeans.Clear();<br />badBeans.Clear();<br />}<br />privateIList<Bean> goodBeans { get; set;}<br />privateIList<Bean> badBeans { get; set;}<br />publicvoidAddBean(Bean bean){<br /> if(bean.size > 10)<br />goodBeans.Add(bean);<br /> else<br />badBeans.Add(bean);<br />}<br />publicvoidUpdateBeans(){<br />BeanData.Update(goodBeans);<br />goodBeans.Clear();<br />badBeans.Clear();<br />}<br />A: create a readonlyaccessor to “sense” thegoodBean state externally<br />
    29. 29. What about the UpdateBeans() method?<br />publicvoidUpdateBeans(){<br />BeanData.Update(goodBeans);<br />goodBeans.Clear();<br />badBeans.Clear();<br />}<br />publicvoidUpdateBeans(){<br />BeanData.Update(goodBeans);<br />goodBeans.Clear();<br />badBeans.Clear();<br />if (OnBeansUpdate != null)<br />OnBeansUpdate();<br />}<br />publiceventActionOnBeansUpdate;<br />
    30. 30. Code Coverage + Continuous Integration<br />Not a silver bullet<br />still need to make sure that we are testing “the right” things, and not just hitting some magical number<br />still need to make sure we have healthy tests<br />Pro tip<br />
    31. 31. Code Coverage + Continuous Integration<br />Creates a base line or smoke test to look for<br />Watch trends over magic percent numbers<br />Pro tip<br />
    32. 32. Code Coverage + Continuous Integration<br />Team City Code Coverage<br />
    33. 33. Code Coverage + Continuous Integration<br />Sonar<br />
    34. 34. Strategy #3<br />
    35. 35. Strategy #3<br />Divide and Conquer <br />(pick your battles)<br />
    36. 36. 36<br />Commitment<br />
    37. 37. 37<br /> Raise your hand and repeat after me,<br />Commitment<br />
    38. 38. 38<br /> Raise your hand and repeat after me,<br />Commitment<br />I will not practice bad code. <br />
    39. 39.
    40. 40. “Resist Legacy Coupling”<br />
    41. 41. “Resist Legacy Coupling”<br />tight coupling = change anywhereaffects everything<br />Legacy Monster<br />Processor<br />Static Config<br />Static Proxy<br />Processor Settings<br />Data Connections<br />Rules Configurations<br />New Functionality<br />Coupling<br />Needs IProxy<br />Coupling<br />static Config class leads to Heavy Weight testing<br />Coupling<br />Coupling<br />Coupling<br />Rules<br />Data<br />don’t reference Config Monster<br />Coupling<br />use DI for only what you need (IProxy)<br />
    42. 42. Introduce SOLID principals on new development… gradually improve code over time<br />http://developingux.com/di/<br />
    43. 43. wrap up<br />
    44. 44. Know your Foe <br />wrap up<br />Use a Safety Net<br />Divide and Conquer<br />
    45. 45. Thank you!<br />Proaction<br />MentorS<br />@calebjenkins<br />http://developingux.com<br />@proactionmentor<br />caleb@proactionmentors.com<br />
    46. 46. Photo Credits<br />© Michael Cummings - http://dreaminpictures.com<br />http://www.flickr.com/photos/boogeyman13/2432667459/<br />http://www.flickr.com/photos/stopthegears/50553611/<br />http://www.flickr.com/photos/pochateca/324414459<br />http://www.flickr.com/photos/27620885@N02/2594362917<br />
    47. 47. http://www.flickr.com/photos/27620885@N02/2594363003<br />http://www.flickr.com/photos/flyingturtle/3976070342/<br />http://www.flickr.com/photos/jfravel/1001472806/<br />http://www.flickr.com/photos/flyingturtle/3976076272/<br />http://www.lostechies.com/blogs/derickbailey/archive/2009/02/11/solid-development-principles-in-motivational-pictures.aspx<br />
    1. A particular slide catching your eye?

      Clipping is a handy way to collect important slides you want to go back to later.

    ×