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

Like this? Share it with your network

Share

Taming the Monster Legacy Code Beast

on

  • 2,050 views

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.

Statistics

Views

Total Views
2,050
Views on SlideShare
1,769
Embed Views
281

Actions

Likes
1
Downloads
13
Comments
0

7 Embeds 281

http://developingux.com 263
http://agile.dzone.com 7
http://mobile.dzone.com 4
http://feeds.feedburner.com 3
https://www.linkedin.com 2
http://www.slideshare.net 1
http://www.linkedin.com 1
More...

Accessibility

Categories

Upload Details

Uploaded via as Microsoft PowerPoint

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment
  • 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 Presentation 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