Your SlideShare is downloading. ×
Taming the Monster Legacy Code Beast
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

Taming the Monster Legacy Code Beast

1,797
views

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 …

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,797
On Slideshare
0
From Embeds
0
Number of Embeds
3
Actions
Shares
0
Downloads
15
Comments
0
Likes
2
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
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.
  • Transcript

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