Skip to content

Commit be261ee

Browse files
committed
minor edits during lab review
1 parent 3280959 commit be261ee

1 file changed

Lines changed: 42 additions & 24 deletions

File tree

Instructions/Labs/LAB_AK_07_simplify_complex_conditionals.md

Lines changed: 42 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ Use the following steps to download the sample projects and open them in Visual
8282
8383
1. Open a browser window in your lab environment.
8484
85-
1. To download a zip file containing the sample app projects, paste the following URL into your browser's address bar: [GitHub Copilot lab - develop code features](https://github.com/MicrosoftLearning/mslearn-github-copilot-dev/raw/refs/heads/main/DownloadableCodeProjects/Downloads/GHCopilotEx7LabApps.zip)
85+
1. To download a zip file containing the sample app projects, open the following URL in your browser: [GitHub Copilot lab - develop code features](https://github.com/MicrosoftLearning/mslearn-github-copilot-dev/raw/refs/heads/main/DownloadableCodeProjects/Downloads/GHCopilotEx7LabApps.zip)
8686
8787
The zip file is named **GHCopilotEx7LabApps.zip**.
8888
@@ -96,33 +96,36 @@ Use the following steps to download the sample projects and open them in Visual
9696
9797
1. Select **Show extracted files when complete**, and then select **Extract**.
9898
99-
1. Open the extracted files folder, then copy the **ECommercePricingEngine** folder to a location that's easy to access, such as your Windows Desktop folder.
99+
1. Copy the **GHCopilotEx7LabApps** folder to a location that's easy to access, such as your Windows Desktop folder.
100100

101-
1. Open the **ECommercePricingEngine** folder in Visual Studio Code.
101+
1. Open the **GHCopilotEx7LabApps** folder in Visual Studio Code.
102102

103103
For example:
104104

105105
1. Open Visual Studio Code in your lab environment.
106106

107107
1. In Visual Studio Code, on the **File** menu, select **Open Folder**.
108108

109-
1. Navigate to the Windows Desktop folder, select **ECommercePricingEngine** and then select **Select Folder**.
109+
1. Navigate to the Windows Desktop folder, select **GHCopilotEx7LabApps** and then select **Select Folder**.
110110

111111
1. In the Visual Studio Code SOLUTION EXPLORER view, verify the following solution structure:
112112

113-
- ECommercePricingEngine\
114-
- ECommercePricingDemo.cs
115-
- ECommercePricingEngine.csproj
116-
- SecurityTest.cs
117-
- LoanApprovalWorkflow\
118-
- LoanApprovalDemo.cs
119-
- LoanApprovalWorkflow.csproj
120-
- SecurityTest.cs
113+
- GHCopilotEx7LabApps\
114+
- ECommercePricingEngine\
115+
- Dependencies\
116+
- ECommercePricingDemo.cs
117+
- SecurityTest.cs
118+
- LoanApprovalWorkflow\
119+
- Dependencies\
120+
- LoanApprovalDemo.cs
121+
- SecurityTest.cs
121122

122-
1. Ensure that the solution builds successfully.
123+
1. Ensure that the two code projects build successfully.
123124

124125
For example, in the SOLUTION EXPLORER view, right-click **ECommercePricingEngine**, and then select **Build**.
125126

127+
You'll see warnings "Cannot convert null literal to non-nullable reference type." when you build the ECommercePricingEngine project. You can ignore these warnings for the purposes of this exercise.
128+
126129
## Part 1: E-commerce pricing engine
127130
128131
In this section, you examine the E-commerce Pricing Engine sample app and use GitHub Copilot to refactor the conditional logic.
@@ -133,31 +136,46 @@ The first step in any refactoring effort is to understand the existing codebase.
133136

134137
Use the following steps to complete this task:
135138

136-
1. Open Visual Studio Code in your lab environment.
139+
1. Ensure that you have the GHCopilotEx7LabApps folder open in Visual Studio Code.
137140

138-
1. In Visual Studio Code, on the **File** menu, select **Open Folder**.
141+
1. Open the GitHub Copilot Chat view.
139142

140-
1. Navigate to the project folder and select the **ECommercePricingEngine** folder.
143+
If the Chat view is not already open, you can open it by selecting the **Chat** icon at the top of the Visual Studio Code window, just to the right of the Search textbox.
141144

142-
The ECommercePricingEngine folder is located at: `DownloadableCodeProjects\standalone-lab-projects\simplify-compex-conditionals\ECommercePricingEngine`
145+
1. In the Chat view, ensure that the chat mode is set to **Ask** and the model is set to **GPT-4.1**.
143146

144-
1. In the EXPLORER view, expand the project structure and locate the **ECommercePricingDemo.cs** file.
147+
The Ask mode allows you to interact with GitHub Copilot to ask questions and get explanations about the code. The GPT-4.1 model, which is included with the GitHub Copilot Free plan, provides advanced capabilities for understanding and generating code.
145148

146-
1. Open the **ECommercePricingDemo.cs** file.
149+
You will be using Agent mode later in this exercise to perform more complex tasks, but for now, Ask mode is sufficient for code analysis and explanations.
147150

148-
This file contains the complex pricing logic that you'll be refactoring. Notice the deeply nested conditional statements in the `CalculateFinalPrice` method.
151+
> [!NOTE]
152+
> The selected model can affect the responses generated by GitHub Copilot. After completing the lab exercise using the recommended settings, you may want to repeat the exercise using different models to compare the results.
149153

150-
1. Select the entire `CalculateFinalPrice` method.
154+
1. In Visual Studio Code, open the **ECommercePricingDemo.cs** file.
155+
156+
This file contains the complex pricing logic that you'll be refactoring. Notice the deeply nested conditional statements in the CalculateFinalPrice method.
157+
158+
1. Locate the **PricingEngine** class, and then select the entire **CalculateFinalPrice** method.
151159
152160
This method contains over 8 levels of nested conditional logic that evaluates membership levels, seasonal events, corporate accounts, subscription services, and various discount scenarios.
153161
154-
1. Right-click the selected code and select **Copilot** > **Explain This**.
162+
1. Right-click the selected code, and then select **Copilot** > **Explain**.
155163
156164
GitHub Copilot will analyze the complex conditional logic and provide an explanation of what the code does, helping you understand the business rules before refactoring.
157165
158-
1. Take a minute to review GitHub Copilot's explanation.
166+
1. Take a few minutes to review GitHub Copilot's explanation.
167+
168+
The explanation should highlight the main discount categories such as the hierarchical membership, coupon applications, bulk purchase incentives, and category-specific rules.
169+
170+
Understanding these business domains is crucial for creating effective helper methods to simplify the logic.
171+
172+
1. If time permits, in the Chat view, enter the following prompt to get a deeper analysis:
173+
174+
```plaintext
175+
@workspace Explain the business logic flow in the CalculateFinalPrice method. What are the different discount paths and how do they interact with each other? What are the key business rules that govern pricing calculations?
176+
```
159177

160-
The explanation should highlight the main discount categories: membership-based discounts, seasonal promotions, coupon applications, bulk purchase incentives, and category-specific rules. Understanding these business domains is crucial for creating effective helper methods.
178+
This will help you understand how the different discount categories interact and what business rules are applied at each step of the pricing calculation.
161179

162180
### Task 2: Identify refactoring opportunities in the E-commerce pricing code
163181

0 commit comments

Comments
 (0)