diff --git a/Upgrading-Legacy-Projects/README.md b/Upgrading-Legacy-Projects/README.md index 7cf0b1b..7926073 100644 --- a/Upgrading-Legacy-Projects/README.md +++ b/Upgrading-Legacy-Projects/README.md @@ -7,33 +7,36 @@ Learning Objectives

-- **Who is this for**: Any technologist that is looking to apply AI pair-programming techniques with GitHub Copilot to perform challenging upgrade scenarios for legacy code. -- **What you'll learn**: You'll use advanced GitHub Copilot techniques that are specifically useful when upgrading projects. These techniques and patterns can be applied to upgrading and revamping projects as well as developing from scratch. -- **What you'll build**: A fully revamped Python project that used Python 2.5 using legacy and deprecated constructs into the latest version of Python 3 available. +- **Who is this for**: Technologists who want to apply AI pair-programming techniques with GitHub Copilot to tackle challenging legacy code upgrade scenarios. +- **What you'll learn**: Advanced Copilot prompting and interaction strategies specifically useful for upgrading and modernizing projects, with techniques that are also applicable to greenfield development. +- **What you'll build**: A fully modernized Python project originally written in Python 2.5, upgraded from legacy and deprecated constructs to the latest version of Python 3. ## Requirements 1. Enable your [GitHub Copilot service](https://github.com/github-copilot/signup) 1. Open [this repository with Codespaces](https://codespaces.new/microsoft/github-copilot-upgrading) - [![Open in GitHub Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/microsoft/github-copilot-upgrading) +💡 You don’t need Python installed locally. Codespaces includes everything you’ll need. + ## Learning Objectives In this workshop, you will: - - Use advanced GitHub Copilot interaction techniques to deal with a legacy project - - Iterate, validate, and refine answers to upgrade the legacy project and validate its correctness - - Apply generic concepts that can improve suggestions and select from different strategies that can yield better results. - - Build a thorough testing strategy to help you identify potential issues and - validate the project in its final state after upgrading. + - Use advanced GitHub Copilot interaction techniques to handle legacy projects. + - Iterate, validate, and refine AI-generated solutions to upgrade code correctly. + - Apply general prompting strategies to improve Copilot suggestions. + - Build and apply a testing strategy to validate the upgraded project. + +Estimated completion time: 60–90 minutes ## :mega: Prerequisites -Before joining the workshop, there is only one prerequisite: you must have a public GitHub account. All resources, dependencies, and data are part of the repository itself. Make sure you have your GitHub Copilot license, trial, or the free version. +You only need a public GitHub account. All dependencies and data are included in this repository. +Make sure you have access to [GitHub Copilot](https://github.com/github-copilot/signup) (via license, trial, or free version). -## Main takeaways +## Key Practices for Upgrading Legacy Projects ### 1. Define Clear Objectives and Requirements @@ -46,7 +49,7 @@ Start by understanding the end goal clearly. What is the result you're after? Fo Identify limitations or exclusions. For example, large language models (LLMs) can have (or lack) enough context to provide the right suggestions. It is up to you, the driver, to make decisions that achieve your goal. Certain business logic might prevent you from adding other external libraries or functionality. For example, if you are upgrading a project that is used in a production environment, you might not be able to add new libraries or functionality that could break the existing code. > [!TIP] -> Focus on being precise with the scope of the problem. If you're unsure, start broad and then progressively narrow down the details. +> Start broad, then progressively narrow scope. Be precise about what success looks like. ### 2. Break Down the Problem into Components @@ -56,10 +59,10 @@ Decompose the problem into smaller, manageable pieces. For example, start with t - Tests, test setup and validation scripts - Configuration and installation process -Ensure you're applying each condition step-by-step. In programming, breaking down a complex function into smaller helper functions can make it easier to write and debug. +Breaking down complexity makes debugging and validation easier. > [!TIP] -> Decomposition is a great way to deal with complexity, as it allows you to focus on one small task at a time. +> Decomposition helps you focus on one small, solvable task at a time. ### 3. Create slices of work @@ -67,14 +70,14 @@ A slice of work is a small, manageable piece of the overall problem. This is sim This allows you to focus on one small task at a time, and it makes it easier to test and validate the changes. > [!TIP] -> When creating slices of work, thing about the functional testing so that you have an easy way to test the changes. This can be as simple as creating a test script that validates the changes or creating a test suite that runs all the tests in the project. +> When creating slices, think about functional testing so you can easily validate changes. ### 4. Iterate and Refine the Solution Start simple, then refine. In complex problems, initial attempts are rarely perfect. Start by generating a basic solution and progressively build on it. > [!TIP] -> With every iteration, test and verify against expected outcomes to ensure the result is moving in the right direction. +> With each iteration, run tests and compare outcomes against expectations. ### 5. Use Examples to Clarify Requirements When creating prompts for AI models or explaining problems, provide examples. An example can illustrate your expectations, making the task clearer for anyone or anything (including tools like GitHub Copilot) involved in solving the problem. @@ -82,7 +85,7 @@ When creating prompts for AI models or explaining problems, provide examples. An For instance, with legacy code, you could explain what the inputs and expected outputs can be while including the logic to accomplish the task > [!TIP] -> Example-driven problem-solving helps align understanding. It's especially useful for ambiguous tasks. +> Example-driven problem-solving is especially effective for ambiguous tasks. ### 6. Identify Patterns and Reuse Solutions Recognize common patterns in your problem and reuse solutions where applicable. An obvious example of this in legacy Python projects is the use of exception handling in Python 2.5 would create a `SyntaxError` in Python 3+. @@ -90,15 +93,15 @@ Recognize common patterns in your problem and reuse solutions where applicable. Sometimes in legacy projects it is common to create functions that handle either case or even modules that can do imports depending on the Python version. This is a common pattern in legacy projects that can be reused in other projects. > [!TIP] -> Recognizing patterns is a hallmark of experience. As you encounter similar problems repeatedly, you'll start to see similarities that can speed up your process. +> Recognizing patterns helps speed up future upgrades. ### 7. Use Constraints and Edge Cases for Robustness -Think about edge cases and exceptions. Complex problems often involve handling not just the "ideal" data, but also the "edge" or "outlier" cases that might break a naive solution. Ensure that your prompt or solution accounts for these edge cases. +Consider edge cases and exceptions. Complex problems rarely involve only 'ideal' inputs—outliers and unusual scenarios can break simple solutions. Make sure your prompt or implementation anticipates and handles these cases. In legacy code, this might mean considering how the code behaves with unexpected inputs, which would guide you to write new tests or modify existing ones. > [!TIP] -> Thinking through edge cases helps you build more resilient, generalized solutions. Always put an added emphasis in testing and creating a robust test suite to validate your changes. +> Emphasize building a comprehensive test suite to validate changes. ### 8. Use Tools Effectively Whether you’re using GitHub Copilot, your editor auto-completion, or another form of automation, leverage the tools at your disposal but make sure you're guiding them with the right context. Tools are great for speeding up the generation, but they still need well-structured inputs and validation from you. @@ -106,7 +109,7 @@ Whether you’re using GitHub Copilot, your editor auto-completion, or another f For GitHub Copilot, ensure that your prompts are detailed, but concise. Tools often work best when given structured input that leaves little ambiguity. > [!TIP] -> Be specific with your tools, but also check results, as tools might not always fully understand context unless properly guided. +> Guide your tools with context and always verify their output. ### 9. Test and Validate @@ -115,23 +118,20 @@ Testing and validation are key to ensuring that your solution works as expected. Testing ensures that both the expected and unexpected situations are handled correctly. > [!TIP] -> Always have a validation step built into your process to catch mistakes early. - -Generalization for Other Use Cases: -For writing code or algorithms: The same concepts apply when generating functions, classes, or workflows. Clearly define input, expected output, edge cases, and iterate to refine. - -For AI model prompts: When asking for something complex (like generating code, text, or designs), give clear objectives, break down the problem, provide context, and iterate. - -For design or content generation: Define the purpose, break down design elements, and provide examples or inspiration, then refine based on feedback. - -Final Thoughts: -Complex generation problems often involve a balance of clarity, decomposition, iteration, and validation. Whether it's an SQL query or any other task, keeping these concepts in mind will allow you to generate more accurate, efficient, and reliable results. +> Always include a validation step to catch mistakes early. +**Generalization for Other Use Cases:** +These principles apply to a wide range of scenarios: +- _Coding & algorithms:_ Define inputs, outputs, and edge cases, then iterate. +- _AI prompting:_ Break down tasks, provide context, and refine results. +- _Design & content:_ Define purpose, provide examples, refine based on feedback. +**Final Thoughts:** +Tackling complex generation tasks requires a balance of clarity, decomposition, iteration, and validation. Whether you're writing an SQL query or solving another challenge, applying these principles helps produce results that are more accurate, efficient, and reliable. ## :books: Resources -Although not required, some of the features this workshop covers are in these Microsoft Learning modules: +Although not required, some of the features this workshop covers are in these Microsoft Learn modules: - [Code with GitHub Codespaces](https://learn.microsoft.com/training/modules/code-with-github-codespaces/) - [Using advanced GitHub Copilot features](https://learn.microsoft.com/training/modules/advanced-github-copilot/)