You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
-**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.
11
-
-**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.
12
-
-**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.
10
+
-**Who is this for**: Technologists who want to apply AI pair-programming techniques with GitHub Copilot to tackle challenging legacy code upgrade scenarios.
11
+
-**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.
12
+
-**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.
13
13
14
14
## Requirements
15
15
16
16
1. Enable your [GitHub Copilot service](https://github.com/github-copilot/signup)
17
17
1. Open [this repository with Codespaces](https://codespaces.new/microsoft/github-copilot-upgrading)
18
18
19
-
20
19
[](https://codespaces.new/microsoft/github-copilot-upgrading)
21
20
21
+
💡 You don’t need Python installed locally. Codespaces includes everything you’ll need.
22
+
22
23
## Learning Objectives
23
24
24
25
In this workshop, you will:
25
26
26
-
- Use advanced GitHub Copilot interaction techniques to deal with a legacy project
27
-
- Iterate, validate, and refine answers to upgrade the legacy project and validate its correctness
28
-
- Apply generic concepts that can improve suggestions and select from different strategies that can yield better results.
29
-
- Build a thorough testing strategy to help you identify potential issues and
30
-
validate the project in its final state after upgrading.
27
+
- Use advanced GitHub Copilot interaction techniques to handle legacy projects.
28
+
- Iterate, validate, and refine AI-generated solutions to upgrade code correctly.
29
+
- Apply general prompting strategies to improve Copilot suggestions.
30
+
- Build and apply a testing strategy to validate the upgraded project.
31
+
32
+
Estimated completion time: 60–90 minutes
31
33
32
34
## :mega: Prerequisites
33
35
34
-
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.
36
+
You only need a public GitHub account. All dependencies and data are included in this repository.
37
+
Make sure you have access to [GitHub Copilot](https://github.com/github-copilot/signup) (via license, trial, or free version).
35
38
36
-
## Main takeaways
39
+
## Key Practices for Upgrading Legacy Projects
37
40
38
41
### 1. Define Clear Objectives and Requirements
39
42
@@ -46,7 +49,7 @@ Start by understanding the end goal clearly. What is the result you're after? Fo
46
49
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.
47
50
48
51
> [!TIP]
49
-
> Focus on being precise with the scope of the problem. If you're unsure, start broad and then progressively narrow down the details.
52
+
> Start broad, then progressively narrow scope. Be precise about what success looks like.
50
53
51
54
### 2. Break Down the Problem into Components
52
55
@@ -56,57 +59,57 @@ Decompose the problem into smaller, manageable pieces. For example, start with t
56
59
- Tests, test setup and validation scripts
57
60
- Configuration and installation process
58
61
59
-
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.
62
+
Breaking down complexity makes debugging and validation easier.
60
63
61
64
> [!TIP]
62
-
> Decomposition is a great way to deal with complexity, as it allows you to focus on one small task at a time.
65
+
> Decomposition helps you focus on one small, solvable task at a time.
63
66
64
67
### 3. Create slices of work
65
68
66
69
A slice of work is a small, manageable piece of the overall problem. This is similar to breaking down the problem into components, but it focuses on the specific tasks that need to be completed. Think of this like a functional test that validates a specific feature or functionality. For example, if you're upgrading a legacy project, you might want to create a slice of work that focuses on upgrading a single library or function.
67
70
This allows you to focus on one small task at a time, and it makes it easier to test and validate the changes.
68
71
69
72
> [!TIP]
70
-
> 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.
73
+
> When creating slices, think about functional testing so you can easily validate changes.
71
74
72
75
### 4. Iterate and Refine the Solution
73
76
Start simple, then refine. In complex problems, initial attempts are rarely perfect. Start by generating a basic solution and progressively build on it.
74
77
75
78
76
79
> [!TIP]
77
-
> With every iteration, test and verify against expected outcomes to ensure the result is moving in the right direction.
80
+
> With each iteration, run tests and compare outcomes against expectations.
78
81
79
82
### 5. Use Examples to Clarify Requirements
80
83
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.
81
84
82
85
For instance, with legacy code, you could explain what the inputs and expected outputs can be while including the logic to accomplish the task
83
86
84
87
> [!TIP]
85
-
> Example-driven problem-solving helps align understanding. It's especially useful for ambiguous tasks.
88
+
> Example-driven problem-solving is especially effective for ambiguous tasks.
86
89
87
90
### 6. Identify Patterns and Reuse Solutions
88
91
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+.
89
92
90
93
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.
91
94
92
95
> [!TIP]
93
-
> 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.
96
+
> Recognizing patterns helps speed up future upgrades.
94
97
95
98
### 7. Use Constraints and Edge Cases for Robustness
96
-
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.
99
+
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.
97
100
98
101
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.
99
102
100
103
> [!TIP]
101
-
> 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.
104
+
> Emphasize building a comprehensive test suite to validate changes.
102
105
103
106
### 8. Use Tools Effectively
104
107
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.
105
108
106
109
For GitHub Copilot, ensure that your prompts are detailed, but concise. Tools often work best when given structured input that leaves little ambiguity.
107
110
108
111
> [!TIP]
109
-
> Be specific with your tools, but also check results, as tools might not always fully understand context unless properly guided.
112
+
> Guide your tools with context and always verify their output.
110
113
111
114
112
115
### 9. Test and Validate
@@ -115,23 +118,20 @@ Testing and validation are key to ensuring that your solution works as expected.
115
118
Testing ensures that both the expected and unexpected situations are handled correctly.
116
119
117
120
> [!TIP]
118
-
> Always have a validation step built into your process to catch mistakes early.
119
-
120
-
Generalization for Other Use Cases:
121
-
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.
122
-
123
-
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.
124
-
125
-
For design or content generation: Define the purpose, break down design elements, and provide examples or inspiration, then refine based on feedback.
126
-
127
-
Final Thoughts:
128
-
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.
121
+
> Always include a validation step to catch mistakes early.
129
122
123
+
**Generalization for Other Use Cases:**
124
+
These principles apply to a wide range of scenarios:
125
+
-_Coding & algorithms:_ Define inputs, outputs, and edge cases, then iterate.
126
+
-_AI prompting:_ Break down tasks, provide context, and refine results.
127
+
-_Design & content:_ Define purpose, provide examples, refine based on feedback.
130
128
129
+
**Final Thoughts:**
130
+
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.
131
131
132
132
## :books: Resources
133
133
134
-
Although not required, some of the features this workshop covers are in these Microsoft Learning modules:
134
+
Although not required, some of the features this workshop covers are in these Microsoft Learn modules:
135
135
136
136
-[Code with GitHub Codespaces](https://learn.microsoft.com/training/modules/code-with-github-codespaces/)
0 commit comments