SlideShare una empresa de Scribd logo
1 de 27
Don’t rewrite – Reengineer!

SOFTWARE REENGINEERING:

        INJECTING QUALITY INTO
        EXISTING SYSTEMS
Who Am I?
 Brad Irby

   http://twitter.com/bradirby
   Brad@BradIrby.com
   Blog: BradIrby.com
   New Book: Reengineering .NET

 25 Years Experience in Application Design and
  Architecture
 Specialist in Application Reengineering and
    Architecture for .NET Applications

                                           Brad Irby Reengineering Series
Who are You?

 Who is religiously using Unit Tests?


 Who has a Continuous Integration Server?


 Who is using an IoC Container?


 Who is working on a Legacy App?


                                         Brad Irby Reengineering Series
Agenda
 Quickly Review the Business Case
   Why Reengineer instead of Rewrite


 Laying the Groundwork
   Prerequisites and Suggestions
   Basic Workflow
   What to do first


 Specific Techniques
   How to handle some situations that will arise
    during the project

                                           Brad Irby Reengineering Series
Goal of Reengineering
 Continuous Release with No Feature Freeze


 Continued Revenue Stream


 Continuous Improvement
   SOLID
   DRY


       Fix the Plane in the Air
                                      Brad Irby Reengineering Series
Advantages of Reengineering
 Maintains Existing Logic
   Business Logic
   Established Processes
   Side Effects
 Go at your own pace
   Fits well with Agile
 Fewer Errors Interpreting Existing System
   Outdated documentation
   Code spelunking
 Continuous QA


                  Reduced Risk
                                          Brad Irby Reengineering Series
Advantages of Reengineering
 Business logic already complete
   No need to recreate it
 Can use outside talent
   In house team can continue adding features
 Shorter Timeline to establish patterns
   Medium size solution: 6 months
   Large Solution: 9 months




 25% of the cost of a Rewrite
                                          Brad Irby Reengineering Series
Starting Out - Code Review
   Establish validity of MVC or MVP
       Everybody claims it, few have it
       Where does business logic live? Should be in Controller/Presenter

   Count Number of Static Classes
       Pure constant or enum classes don’t count

   Count Activator Calls
       Often used to get around bad references and circular references
       The more you have, the more time you should budget

   Count Average Num References per Project
       Look at validity of references
       Should one project reference another?

   Many Other Metrics


Know WhatYou Are Up Against                                               Brad Irby Reengineering Series
Lay Groundwork (Basics)
 Decide Unit Test Framework
     External GUI runner
     Integrated into VS2008/2010/2012 (ReSharper)
     Integrates with Code Coverage
     Integrates with TFS/Perforce/SVN/Git?
     Has Command Line
     Reporting
       Possibly needs data export


 Possibilities: NUnit, MbUnit, MSTest

Spend the time to do this right
                                              Brad Irby Reengineering Series
Lay Groundwork (Basics)
  Setup Build Server
      Nightly build a must
      Email build Success/Fail
      Continuous Integration helps a lot
      Cruise Control and CCTray

  Nightly runs of integration tests
  Unit tests run on each check-in


Peer Pressure Not To Break Builds           Brad Irby Reengineering Series
Lay Groundwork (Basics)
 Divide Tests
   Unit tests (run on each check-in)
   Integration tests (run at least nightly)
   Performance Tests (run at least nightly)

 Install test runner
   TestDriven or Resharper are good
   VS2012 runner built in


 Training is an ongoing effort
                                               Brad Irby Reengineering Series
Lay Groundwork (Advanced)
 Decide on Code Coverage
   NCover, DotCover or MS Team Coverage
   Stats should run nightly to develop trend
   After time, decide on max Cyclomatic Complexity

 Decide on Mocking Framework
   Free: Moq, Rhino mocks, others
      Difficult to use with Reengineering
   Paid (but worth it): JustMock
      Specializes in mocking legacy code

   Get Team Buy-in on these                  Brad Irby Reengineering Series
Preliminary Code Cleanup
  Develop Project Structure Strategy

  Careful of too many partial classes (Model)
     Bug in VS2008

  Remove unneeded Usings and References

  Clean up warnings
    Set “Warnings as Errors”

  Move Constants and Enums to static classes


Code Changes Good for Junior Dev
                                             Brad Irby Reengineering Series
Step 1 - Add Foundation
 Inversion of Control Container
   Enabled loose coupling


 BootStrapper
   Use to setup IoC container


 Service Locator
   Dependency Injection too difficult for
    Reengineering

                                             Brad Irby Reengineering Series
Inversion of Control Container

 Enables a way for code to use classes without
  knowing what they are or how to create them
   Centralized Service Management
   Provides Loose Coupling
   Allows Separation of Concerns
   Improves Testability
   Possibilities: Unity, Castle Windsor, StructureMap



Difficult Transition for Inexperienced          Brad Irby Reengineering Series
BootStrapper
 Provides central area for app configuration
   Central Registration of classes and interfaces


 Makes test setup easier and more reliable
   Each test can setup IoC as appropriate


 Static or Dynamic discovery of modules
   Load by Hand
   Scan disk looking for modules to load



  All Services Need Interfaces                  Brad Irby Reengineering Series
Service Locator
 Provides anonymous access to app services


 Service consumer need only know about the
  interface, not the service itself

 Location services can be extended to objects
  also (forms, regions, etc.)



                                      Brad Irby Reengineering Series
How to Convert to

Inversion of Control

   BootStrapper

  Service Locator


                     Brad Irby Reengineering Series
Why Service Locator?
 Limits refactoring to the components at hand
   Dependency Injection requires update from root to
     leaves
       Constructor Injection
       Property Injection


 OnDemand Creation of Dependencies
   Do not have to create classes that are never used
   Advantage in tests and production code


                                               Brad Irby Reengineering Series
Summary so far

 Added basic components – less than 1 day


 No affect on existing legacy code yet


 App will build and deploy like normal




                                          Brad Irby Reengineering Series
Step 2 – Entity Model and Repo
 Implement Repository Pattern
    Allows much more versatility in testing
    Divorces app from persistence technology
       Oracle, MS SQL, MySQL
    Possible even without Entities

 Convert to Entities (if possible)
    Ensure data model is in project by itself
    Allows use from old and new code
    Separates data concerns from code concerns


Add Now to Reengineer Incrementally               Brad Irby Reengineering Series
How to Convert to

  Entity Model

   Repository




                    Brad Irby Reengineering Series
Step 3 – Create Services
   Web or Desktop
     Logger
        Log4Net or home-grown logger
     Repository (if not already there)
     Validation Manager
        Validate state of domain entities
        Microsoft Validation Block is good

   Desktop Apps
     Session State Manager
        Only use this during conversion – should disappear when done
     Dialog Service
     Message Aggregator
        MessageEvents takes planning

Basic Services Required for Decoupling
                                                           Brad Irby Reengineering Series
Step 4 - Migrate Services
 Look for singleton patterns
    Search for “.Instance”
    Move to Service Locator
 Look for Services with no Interfaces
    ReSharper can create interface for you
 Look for Static Services Classes
    Difficult to Mock and Test
    Cause problems testing other things
    Search for “public static class”
    Change to Normal class (singleton via container)

 Small Changes Can Have Big Benefits         Brad Irby Reengineering Series
Step 5 – Views & Controllers
  Architect does first ones
  Start with Easiest
    Lots of infrastructure needed for first one
    Don’t complicate with difficult workflow
    Use views that don’t need data binding if possible
  Next, most difficult
  Then involve the rest of the team


Build Example Patterns for Others
                                              Brad Irby Reengineering Series
Parting Comments
  Bootstrapper
    Add Extension methods to setup mocks
  Mocking
    Make plenty of Mocking examples for others to
     learn from – steep learning curve
  Insist on 75% or more coverage on new code
      80% is sufficient - 100% too difficult
  Common mistake – overloading TestSetup

Reengineering – 25% of the cost of Rewrite
                                                Brad Irby Reengineering Series
Who Am I?
 Brad Irby

   http://twitter.com/bradirby
   Brad@BradIrby.com
   Blog: BradIrby.com
   New Book: Reengineering .NET

 25 Years Experience in Application Design and
  Architecture
 Specialist in Application Reengineering and
  Architecture for .NET Applications


                                           Brad Irby Reengineering Series

Más contenido relacionado

La actualidad más candente

Mobile to Mainframe - the Challenges of Enterprise DevOps Adoption
Mobile to Mainframe - the Challenges of Enterprise DevOps AdoptionMobile to Mainframe - the Challenges of Enterprise DevOps Adoption
Mobile to Mainframe - the Challenges of Enterprise DevOps Adoption
Sanjeev Sharma
 
Model-Based Testing for ALM Octane: Better tests, built faster
Model-Based Testing for ALM Octane: Better tests, built faster Model-Based Testing for ALM Octane: Better tests, built faster
Model-Based Testing for ALM Octane: Better tests, built faster
Curiosity Software Ireland
 
SystemVerilog Assertions (SVA) in the Design/Verification Process
SystemVerilog Assertions (SVA) in the Design/Verification ProcessSystemVerilog Assertions (SVA) in the Design/Verification Process
SystemVerilog Assertions (SVA) in the Design/Verification Process
DVClub
 
Introducing Obsidian Software and RAVEN-GCS for PowerPC
Introducing Obsidian Software and RAVEN-GCS for PowerPCIntroducing Obsidian Software and RAVEN-GCS for PowerPC
Introducing Obsidian Software and RAVEN-GCS for PowerPC
DVClub
 
Large scale agile development practices
Large scale agile development practicesLarge scale agile development practices
Large scale agile development practices
Skills Matter
 
Shirly Ronen - User story testing activities
Shirly Ronen - User story testing activitiesShirly Ronen - User story testing activities
Shirly Ronen - User story testing activities
AgileSparks
 
Shirly Ronen - rapid release flow and agile testing-as
Shirly Ronen - rapid release flow and agile testing-asShirly Ronen - rapid release flow and agile testing-as
Shirly Ronen - rapid release flow and agile testing-as
AgileSparks
 

La actualidad más candente (20)

Team Foundation Server Process Templates For Effective Project Management
Team Foundation Server Process Templates For Effective Project ManagementTeam Foundation Server Process Templates For Effective Project Management
Team Foundation Server Process Templates For Effective Project Management
 
Building Mobile (app) Masterpiece with Distributed Agile
Building Mobile (app) Masterpiece with Distributed AgileBuilding Mobile (app) Masterpiece with Distributed Agile
Building Mobile (app) Masterpiece with Distributed Agile
 
Mobile to Mainframe - the Challenges of Enterprise DevOps Adoption
Mobile to Mainframe - the Challenges of Enterprise DevOps AdoptionMobile to Mainframe - the Challenges of Enterprise DevOps Adoption
Mobile to Mainframe - the Challenges of Enterprise DevOps Adoption
 
Manual testing1
Manual testing1Manual testing1
Manual testing1
 
Testing for continuous delivery with visual studio 2012
Testing for continuous delivery with visual studio 2012Testing for continuous delivery with visual studio 2012
Testing for continuous delivery with visual studio 2012
 
Model-Based Testing for ALM Octane: Better tests, built faster
Model-Based Testing for ALM Octane: Better tests, built faster Model-Based Testing for ALM Octane: Better tests, built faster
Model-Based Testing for ALM Octane: Better tests, built faster
 
SystemVerilog Assertions (SVA) in the Design/Verification Process
SystemVerilog Assertions (SVA) in the Design/Verification ProcessSystemVerilog Assertions (SVA) in the Design/Verification Process
SystemVerilog Assertions (SVA) in the Design/Verification Process
 
Agile Software Development in Practice - A Developer Perspective
Agile Software Development in Practice - A Developer PerspectiveAgile Software Development in Practice - A Developer Perspective
Agile Software Development in Practice - A Developer Perspective
 
Introducing Obsidian Software and RAVEN-GCS for PowerPC
Introducing Obsidian Software and RAVEN-GCS for PowerPCIntroducing Obsidian Software and RAVEN-GCS for PowerPC
Introducing Obsidian Software and RAVEN-GCS for PowerPC
 
Large scale agile development practices
Large scale agile development practicesLarge scale agile development practices
Large scale agile development practices
 
How Microsoft ALM Tools Can Improve Your Bottom Line
How Microsoft ALM Tools Can Improve Your Bottom LineHow Microsoft ALM Tools Can Improve Your Bottom Line
How Microsoft ALM Tools Can Improve Your Bottom Line
 
Continous integration-leon-kehl-2010
Continous integration-leon-kehl-2010Continous integration-leon-kehl-2010
Continous integration-leon-kehl-2010
 
Ibm innovate ci for system z
Ibm innovate ci for system zIbm innovate ci for system z
Ibm innovate ci for system z
 
Dayal rtp q2_07
Dayal rtp q2_07Dayal rtp q2_07
Dayal rtp q2_07
 
TDD vs. ATDD - What, Why, Which, When & Where
TDD vs. ATDD - What, Why, Which, When & WhereTDD vs. ATDD - What, Why, Which, When & Where
TDD vs. ATDD - What, Why, Which, When & Where
 
Shirly Ronen - User story testing activities
Shirly Ronen - User story testing activitiesShirly Ronen - User story testing activities
Shirly Ronen - User story testing activities
 
Essential practices and thinking tools for Agile Adoption
Essential practices and thinking tools for Agile AdoptionEssential practices and thinking tools for Agile Adoption
Essential practices and thinking tools for Agile Adoption
 
Shirly Ronen - rapid release flow and agile testing-as
Shirly Ronen - rapid release flow and agile testing-asShirly Ronen - rapid release flow and agile testing-as
Shirly Ronen - rapid release flow and agile testing-as
 
Why Test Driven Development?
Why Test Driven Development?Why Test Driven Development?
Why Test Driven Development?
 
Do The Right Thing - Empowering Your Test Teams
Do The Right Thing - Empowering Your Test TeamsDo The Right Thing - Empowering Your Test Teams
Do The Right Thing - Empowering Your Test Teams
 

Destacado (6)

雲端科技發展下的資訊安全問題
雲端科技發展下的資訊安全問題雲端科技發展下的資訊安全問題
雲端科技發展下的資訊安全問題
 
Software Reengineering
Software ReengineeringSoftware Reengineering
Software Reengineering
 
Rejunevating software reengineering processes
Rejunevating software reengineering processesRejunevating software reengineering processes
Rejunevating software reengineering processes
 
Business Process Reengineering Complete
Business Process Reengineering   CompleteBusiness Process Reengineering   Complete
Business Process Reengineering Complete
 
SEO: Getting Personal
SEO: Getting PersonalSEO: Getting Personal
SEO: Getting Personal
 
Slideshare ppt
Slideshare pptSlideshare ppt
Slideshare ppt
 

Similar a Software reengineering for Developers

06 operations and feedback dap-kabel
06   operations and feedback dap-kabel06   operations and feedback dap-kabel
06 operations and feedback dap-kabel
David Alvarez Palomo
 
Alm Specialist Toolkit Team System 2008 Deep Dive
Alm Specialist Toolkit   Team System 2008 Deep DiveAlm Specialist Toolkit   Team System 2008 Deep Dive
Alm Specialist Toolkit Team System 2008 Deep Dive
Christian Thilmany
 
WSO2Con US 2013 - Keynote: Developing Enterprise Apps In the Cloud
WSO2Con US 2013 - Keynote: Developing Enterprise Apps In the CloudWSO2Con US 2013 - Keynote: Developing Enterprise Apps In the Cloud
WSO2Con US 2013 - Keynote: Developing Enterprise Apps In the Cloud
WSO2
 

Similar a Software reengineering for Developers (20)

Agile Development in .NET
Agile Development in .NETAgile Development in .NET
Agile Development in .NET
 
Using Lean Thinking to Identify and Address Delivery Pipeline Bottlenecks
Using Lean Thinking to Identify and Address Delivery Pipeline BottlenecksUsing Lean Thinking to Identify and Address Delivery Pipeline Bottlenecks
Using Lean Thinking to Identify and Address Delivery Pipeline Bottlenecks
 
Elements of DDD with ASP.NET MVC & Entity Framework Code First
Elements of DDD with ASP.NET MVC & Entity Framework Code FirstElements of DDD with ASP.NET MVC & Entity Framework Code First
Elements of DDD with ASP.NET MVC & Entity Framework Code First
 
TDD with BizTalk
TDD with BizTalkTDD with BizTalk
TDD with BizTalk
 
WSO2Con EU 2015: Keynote - The Containerization of the Developer Workspace
WSO2Con EU 2015: Keynote - The Containerization of the Developer WorkspaceWSO2Con EU 2015: Keynote - The Containerization of the Developer Workspace
WSO2Con EU 2015: Keynote - The Containerization of the Developer Workspace
 
Ci tips and_tricks_linards_liepins
Ci tips and_tricks_linards_liepinsCi tips and_tricks_linards_liepins
Ci tips and_tricks_linards_liepins
 
visual basic 2005 programmer certification
visual basic 2005 programmer certificationvisual basic 2005 programmer certification
visual basic 2005 programmer certification
 
How to Build and Maintain Quality Drupal Sites with Automated Testing
How to Build and Maintain Quality Drupal Sites with Automated TestingHow to Build and Maintain Quality Drupal Sites with Automated Testing
How to Build and Maintain Quality Drupal Sites with Automated Testing
 
06 operations and feedback dap-kabel
06   operations and feedback dap-kabel06   operations and feedback dap-kabel
06 operations and feedback dap-kabel
 
Chef for DevOps - an Introduction
Chef for DevOps - an IntroductionChef for DevOps - an Introduction
Chef for DevOps - an Introduction
 
Best Online Training Institute on Oracle SOA/BPEL
Best Online Training Institute on Oracle SOA/BPELBest Online Training Institute on Oracle SOA/BPEL
Best Online Training Institute on Oracle SOA/BPEL
 
Team Foundation Server 2013 Lansering
Team Foundation Server 2013 LanseringTeam Foundation Server 2013 Lansering
Team Foundation Server 2013 Lansering
 
Alm Specialist Toolkit Team System 2008 Deep Dive
Alm Specialist Toolkit   Team System 2008 Deep DiveAlm Specialist Toolkit   Team System 2008 Deep Dive
Alm Specialist Toolkit Team System 2008 Deep Dive
 
Leading the Transformation
Leading the TransformationLeading the Transformation
Leading the Transformation
 
Build for the future
Build for the futureBuild for the future
Build for the future
 
WSO2Con US 2013 - Keynote: Developing Enterprise Apps In the Cloud
WSO2Con US 2013 - Keynote: Developing Enterprise Apps In the CloudWSO2Con US 2013 - Keynote: Developing Enterprise Apps In the Cloud
WSO2Con US 2013 - Keynote: Developing Enterprise Apps In the Cloud
 
Microsoft DevOps Solution - DevOps
Microsoft DevOps Solution - DevOps  Microsoft DevOps Solution - DevOps
Microsoft DevOps Solution - DevOps
 
Behavior Driven Development by Example
Behavior Driven Development by ExampleBehavior Driven Development by Example
Behavior Driven Development by Example
 
Beyond Scrum: Scaling Agile with Continuous Delivery and Subversion
Beyond Scrum: Scaling Agile with Continuous Delivery and SubversionBeyond Scrum: Scaling Agile with Continuous Delivery and Subversion
Beyond Scrum: Scaling Agile with Continuous Delivery and Subversion
 
Clean architecture with asp.net core
Clean architecture with asp.net coreClean architecture with asp.net core
Clean architecture with asp.net core
 

Software reengineering for Developers

  • 1. Don’t rewrite – Reengineer! SOFTWARE REENGINEERING: INJECTING QUALITY INTO EXISTING SYSTEMS
  • 2. Who Am I?  Brad Irby  http://twitter.com/bradirby  Brad@BradIrby.com  Blog: BradIrby.com  New Book: Reengineering .NET  25 Years Experience in Application Design and Architecture  Specialist in Application Reengineering and Architecture for .NET Applications Brad Irby Reengineering Series
  • 3. Who are You?  Who is religiously using Unit Tests?  Who has a Continuous Integration Server?  Who is using an IoC Container?  Who is working on a Legacy App? Brad Irby Reengineering Series
  • 4. Agenda  Quickly Review the Business Case  Why Reengineer instead of Rewrite  Laying the Groundwork  Prerequisites and Suggestions  Basic Workflow  What to do first  Specific Techniques  How to handle some situations that will arise during the project Brad Irby Reengineering Series
  • 5. Goal of Reengineering  Continuous Release with No Feature Freeze  Continued Revenue Stream  Continuous Improvement  SOLID  DRY Fix the Plane in the Air Brad Irby Reengineering Series
  • 6. Advantages of Reengineering  Maintains Existing Logic  Business Logic  Established Processes  Side Effects  Go at your own pace  Fits well with Agile  Fewer Errors Interpreting Existing System  Outdated documentation  Code spelunking  Continuous QA Reduced Risk Brad Irby Reengineering Series
  • 7. Advantages of Reengineering  Business logic already complete  No need to recreate it  Can use outside talent  In house team can continue adding features  Shorter Timeline to establish patterns  Medium size solution: 6 months  Large Solution: 9 months 25% of the cost of a Rewrite Brad Irby Reengineering Series
  • 8. Starting Out - Code Review  Establish validity of MVC or MVP  Everybody claims it, few have it  Where does business logic live? Should be in Controller/Presenter  Count Number of Static Classes  Pure constant or enum classes don’t count  Count Activator Calls  Often used to get around bad references and circular references  The more you have, the more time you should budget  Count Average Num References per Project  Look at validity of references  Should one project reference another?  Many Other Metrics Know WhatYou Are Up Against Brad Irby Reengineering Series
  • 9. Lay Groundwork (Basics)  Decide Unit Test Framework  External GUI runner  Integrated into VS2008/2010/2012 (ReSharper)  Integrates with Code Coverage  Integrates with TFS/Perforce/SVN/Git?  Has Command Line  Reporting  Possibly needs data export  Possibilities: NUnit, MbUnit, MSTest Spend the time to do this right Brad Irby Reengineering Series
  • 10. Lay Groundwork (Basics)  Setup Build Server  Nightly build a must  Email build Success/Fail  Continuous Integration helps a lot  Cruise Control and CCTray  Nightly runs of integration tests  Unit tests run on each check-in Peer Pressure Not To Break Builds Brad Irby Reengineering Series
  • 11. Lay Groundwork (Basics)  Divide Tests  Unit tests (run on each check-in)  Integration tests (run at least nightly)  Performance Tests (run at least nightly)  Install test runner  TestDriven or Resharper are good  VS2012 runner built in Training is an ongoing effort Brad Irby Reengineering Series
  • 12. Lay Groundwork (Advanced)  Decide on Code Coverage  NCover, DotCover or MS Team Coverage  Stats should run nightly to develop trend  After time, decide on max Cyclomatic Complexity  Decide on Mocking Framework  Free: Moq, Rhino mocks, others  Difficult to use with Reengineering  Paid (but worth it): JustMock  Specializes in mocking legacy code Get Team Buy-in on these Brad Irby Reengineering Series
  • 13. Preliminary Code Cleanup  Develop Project Structure Strategy  Careful of too many partial classes (Model)  Bug in VS2008  Remove unneeded Usings and References  Clean up warnings  Set “Warnings as Errors”  Move Constants and Enums to static classes Code Changes Good for Junior Dev Brad Irby Reengineering Series
  • 14. Step 1 - Add Foundation  Inversion of Control Container  Enabled loose coupling  BootStrapper  Use to setup IoC container  Service Locator  Dependency Injection too difficult for Reengineering Brad Irby Reengineering Series
  • 15. Inversion of Control Container  Enables a way for code to use classes without knowing what they are or how to create them  Centralized Service Management  Provides Loose Coupling  Allows Separation of Concerns  Improves Testability  Possibilities: Unity, Castle Windsor, StructureMap Difficult Transition for Inexperienced Brad Irby Reengineering Series
  • 16. BootStrapper  Provides central area for app configuration  Central Registration of classes and interfaces  Makes test setup easier and more reliable  Each test can setup IoC as appropriate  Static or Dynamic discovery of modules  Load by Hand  Scan disk looking for modules to load All Services Need Interfaces Brad Irby Reengineering Series
  • 17. Service Locator  Provides anonymous access to app services  Service consumer need only know about the interface, not the service itself  Location services can be extended to objects also (forms, regions, etc.) Brad Irby Reengineering Series
  • 18. How to Convert to Inversion of Control BootStrapper Service Locator Brad Irby Reengineering Series
  • 19. Why Service Locator?  Limits refactoring to the components at hand  Dependency Injection requires update from root to leaves  Constructor Injection  Property Injection  OnDemand Creation of Dependencies  Do not have to create classes that are never used  Advantage in tests and production code Brad Irby Reengineering Series
  • 20. Summary so far  Added basic components – less than 1 day  No affect on existing legacy code yet  App will build and deploy like normal Brad Irby Reengineering Series
  • 21. Step 2 – Entity Model and Repo  Implement Repository Pattern  Allows much more versatility in testing  Divorces app from persistence technology  Oracle, MS SQL, MySQL  Possible even without Entities  Convert to Entities (if possible)  Ensure data model is in project by itself  Allows use from old and new code  Separates data concerns from code concerns Add Now to Reengineer Incrementally Brad Irby Reengineering Series
  • 22. How to Convert to Entity Model Repository Brad Irby Reengineering Series
  • 23. Step 3 – Create Services  Web or Desktop  Logger  Log4Net or home-grown logger  Repository (if not already there)  Validation Manager  Validate state of domain entities  Microsoft Validation Block is good  Desktop Apps  Session State Manager  Only use this during conversion – should disappear when done  Dialog Service  Message Aggregator  MessageEvents takes planning Basic Services Required for Decoupling Brad Irby Reengineering Series
  • 24. Step 4 - Migrate Services  Look for singleton patterns  Search for “.Instance”  Move to Service Locator  Look for Services with no Interfaces  ReSharper can create interface for you  Look for Static Services Classes  Difficult to Mock and Test  Cause problems testing other things  Search for “public static class”  Change to Normal class (singleton via container) Small Changes Can Have Big Benefits Brad Irby Reengineering Series
  • 25. Step 5 – Views & Controllers  Architect does first ones  Start with Easiest  Lots of infrastructure needed for first one  Don’t complicate with difficult workflow  Use views that don’t need data binding if possible  Next, most difficult  Then involve the rest of the team Build Example Patterns for Others Brad Irby Reengineering Series
  • 26. Parting Comments  Bootstrapper  Add Extension methods to setup mocks  Mocking  Make plenty of Mocking examples for others to learn from – steep learning curve  Insist on 75% or more coverage on new code  80% is sufficient - 100% too difficult  Common mistake – overloading TestSetup Reengineering – 25% of the cost of Rewrite Brad Irby Reengineering Series
  • 27. Who Am I?  Brad Irby  http://twitter.com/bradirby  Brad@BradIrby.com  Blog: BradIrby.com  New Book: Reengineering .NET  25 Years Experience in Application Design and Architecture  Specialist in Application Reengineering and Architecture for .NET Applications Brad Irby Reengineering Series

Notas del editor

  1. In this presentation we are going to be going through a typical reengineering engagement with a fictional client. We will walk through all the steps necessary to reengineer an existing system from the start to the finish.
  2. These are the main advantages of reengineering over rewriting.A largely ignored factor is that reengineering retains the unintended side effects of the way the current code was implemented. Customer come to depend on the small artifacts in our software, and if we rewrite it those artifacts will be lost without us knowing it. By keeping as much of the business logic as possible, these artifacts are retained, and customers are kept happy.
  3. These are the main advantages of reengineering over rewriting.A largely ignored factor is that reengineering retains the unintended side effects of the way the current code was implemented. Customer come to depend on the small artifacts in our software, and if we rewrite it those artifacts will be lost without us knowing it. By keeping as much of the business logic as possible, these artifacts are retained, and customers are kept happy.
  4. These are the main advantages of reengineering over rewriting.A largely ignored factor is that reengineering retains the unintended side effects of the way the current code was implemented. Customer come to depend on the small artifacts in our software, and if we rewrite it those artifacts will be lost without us knowing it. By keeping as much of the business logic as possible, these artifacts are retained, and customers are kept happy.
  5. First, we analyze the existing code to see what we are up against. This helps us estimate how long the project will take, what infrastructure elements we will need to introduce, and which elements will need to be replaced.
  6. Deciding on a proper unit test framework is an important first step. There are various options depending on various factors in the development environment.
  7. Nightly builds are must. Builds on each checkin are helpful, but not required.
  8. It is best to divide out the integration tests up front since they take so much time to run.Note that training is never done! All new additions must be accompanied by team training to make sure the team adopts the new technology. New infrastructure that nobody uses is worthless.
  9. Code coverage is a very useful tool, helping to measure progress towards complete test coverage.Mocking frameworks can be complicated, so the team should be involved in this decision.