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
Copy file name to clipboardExpand all lines: Instructions/Labs/LAB_AK_07_simplify_complex_conditionals.md
+51-4Lines changed: 51 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,7 +6,10 @@
6
6
7
7
# Simplify complex conditionals using GitHub Copilot
8
8
9
-
This lab exercise guides you through examining and refactoring two complex C# codebases using GitHub Copilot tools: an E-commerce Pricing Engine and a Loan Approval Workflow. Both scenarios feature deeply nested conditional logic that mirrors real-world business rules. The E-commerce scenario focuses on dynamic pricing, discounts, and shipping rules, while the Loan Approval scenario models financial eligibility and fallback loan offers. You will use GitHub Copilot to analyze, explain, and simplify these conditionals into more maintainable structures.
9
+
In this exercise, you use GitHub Copilot to analyze and simplify deeply nested conditional logic that mirrors real-world business rules. You'll work with two sample applications that reflect real-world scenarios:
10
+
11
+
1. E-commerce pricing engine.
12
+
2. Loan approval workflow.
10
13
11
14
This exercise should take approximately **30** minutes to complete.
12
15
@@ -52,7 +55,10 @@ If you're using a hosted lab environment for this exercise:
52
55
53
56
## Exercise scenario
54
57
55
-
You're a software development engineer working for a consulting agency. Your clients have complex C# codebases that require refactoring to improve maintainability and readability. The first codebase is an E-commerce Pricing Engine that calculates dynamic pricing based on various business rules, including membership levels, order values, coupon codes, product categories, and shipping rules. The second codebase is a Loan Approval Workflow that evaluates loan applications based on credit scores, income, employment status, debt ratios, collateral, criminal records, and residency.
58
+
You're a software developer working for a consulting agency. New clients need help refactoring conditional logic to improve code maintainability and readability.
59
+
60
+
- E-commerce pricing demo: The first app is an E-commerce Pricing Engine that calculates dynamic pricing based on various business rules. Conditionals include membership levels, order values, coupon codes, product categories, and shipping rules.
61
+
- Loan approval demo: The second app is a Loan Approval Workflow that evaluates loan applications based on various factors. Conditionals include income, employment status, debt ratios, collateral, and credit history.
56
62
57
63
This exercise includes the following tasks:
58
64
@@ -70,9 +76,50 @@ Part 2: Loan approval workflow
70
76
1. Refactor the loan approval code with GitHub Copilot.
71
77
1. Test the refactored loan approval code.
72
78
79
+
## Download sample projects
80
+
81
+
Use the following steps to download the sample projects and open them in Visual Studio Code:
82
+
83
+
1. Open a browser window in your lab environment.
84
+
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)
86
+
87
+
The zip file is named **GHCopilotEx7LabApps.zip**.
88
+
89
+
1. Extract the files from the **GHCopilotEx7LabApps.zip** file.
90
+
91
+
For example:
92
+
93
+
1. Navigate to the downloads folder in your lab environment.
94
+
95
+
1. Right-click *GHCopilotEx7LabApps.zip*, and thenselect**Extract all**.
96
+
97
+
1. Select **Show extracted files when complete**, and thenselect**Extract**.
98
+
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.
100
+
101
+
1. Open the **ECommercePricingEngine** folder in Visual Studio Code.
102
+
103
+
For example:
104
+
105
+
1. Open Visual Studio Code in your lab environment.
106
+
107
+
1. In Visual Studio Code, on the **File** menu, select **Open Folder**.
108
+
109
+
1. Navigate to the Windows Desktop folder, select **ECommercePricingEngine** and then select **Select Folder**.
110
+
111
+
1. In the Visual Studio Code SOLUTION EXPLORER view, verify the following solution structure:
112
+
113
+
- ECommercePricingEngine\
114
+
- ECommercePricingDemo.cs
115
+
116
+
1. Ensure that the solution builds successfully.
117
+
118
+
For example, in the SOLUTION EXPLORER view, right-click **ECommercePricingEngine**, and then select **Build**.
119
+
73
120
## Part 1: E-commerce pricing engine
74
121
75
-
In this section, you will examine the E-commerce Pricing Engine code and use GitHub Copilot to refactor it.
122
+
In this section, you examine the E-commerce Pricing Engine sample app and use GitHub Copilot to refactor the conditional logic.
76
123
77
124
### Task 1: Review the E-commerce pricing code
78
125
@@ -225,7 +272,7 @@ Use the following steps to complete this task:
225
272
226
273
## Part 2: Loan approval workflow
227
274
228
-
In this section, you will examine the Loan Approval Workflow code and use GitHub Copilot to refactor it.
275
+
In this section, you examine the Loan Approval Workflow sample app and use GitHub Copilot to refactor the conditional logic.
0 commit comments