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.
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…
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
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?
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
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/