共用方式為


Updating existing applications

If your team is updating an existing application, one of its first tasks is to learn the code. To be able to estimate the work that your team will do, it must identify the parts of the code where changes are required, and then determine how far the consequences of the changes will propagate.

Your team can help make sure that the changes that it makes have no negative effects by creating and running unit and system tests. If these tests do not already exist, your team must create them. However, creating an exhaustive set of unit and system tests for an existing application is not required. By understanding the existing structure of the code and the changes that you expect to make, your team can focus on creating the tests that you require to make sure that those changes do not adversely affect the application.

The following actions and tools are recommended when you must update existing code:

  • Understand the existing structure. Use Architecture Explorer, directed graphs, and generated sequence diagrams to find the major components and their dependencies. For more information, see Visualize code.

  • Understand the existing behavior and the changes that are required. Your team should understand the existing behavior when it discusses the new stories in detail. Tag existing stories "as-is," and new stories "to-be." Use those tags as part of file, folder, and model names.

    You can use models to help clarify the user stories. For more information, see Modeling user stories.

  • Stabilize the behavior with tests. Add automated or manual tests to achieve the following:

    • Help you understand the existing behavior of the product.

    • Highlight those aspects of the behavior of the product that will be changed.

    • Make sure that your changes do not break existing functions.

  • Stabilize the architecture with layer diagrams. Create layer diagrams to achieve the following:

    • Help understand the structure of the existing code.

    • Highlight areas for change in the existing code.

    • Make sure that your changes do not unintentionally contravene the existing architecture by introducing unintended dependencies or by putting functions in inappropriate locations.

    For more information, see Stabilizing the application structure by using layer diagrams.

  • Write the required changes as stories, estimate the costs of the stories, and arrange them into a product backlog. When you estimate cost, you will naturally consider the fact that you are updating existing code. Each estimate should include the time that will be taken to understand the existing design and to write automated tests.

    For more information, see Create your backlog.

Further Reading

Working Effectively with Legacy Code, Michael Feathers; Prentice Hall, 2004.