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/20480C_MOD07_LAB_MANUAL.md
+27-27Lines changed: 27 additions & 27 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,7 +6,7 @@
6
6
7
7
The existing JavaScript code for the ContosoConf website has been written without much high-level structure or organization. While this approach is fine for small pieces of code, it will not scale up for a larger project. An unstructured collection of functions and variables scattered throughout a JavaScript file can quickly become unmaintainable.
8
8
9
-
Before implementing more website features by using JavaScript, you decide to refactor the existing code to introduce better organizational practices. The resulting code will be more maintainable and provide a good pattern for implementing future website features.
9
+
Before implementing more JavaScript code to enhance the website, you decide to refactor the existing code for better organizational practices. The resulting code will be more maintainable and provide a good pattern for implementing features in the future.
10
10
11
11
#### Objectives
12
12
@@ -19,58 +19,58 @@ After completing this lab, you will be able to:
19
19
20
20
Estimated Time: **60 minutes**
21
21
22
-
### Exercise 1: Refactoring JavaScript Code to Use Classes and Objects.
22
+
### Exercise 1: Refactoring JavaScript Code to Use Classes and Objects
23
23
24
24
#### Scenario
25
25
26
-
The JavaScript code for the Schedule page has been partially refactored to be more maintainable. In this exercise, you will continue the refactoring process by updating the code for the Schedule page. You will create a new class **ScheduleList**. Then you will move the existing functions and variables relating to the schedule list into this class.
26
+
The JavaScript code for the **Schedule** page has been partially refactored to be more maintainable. In this exercise, you will continue the refactoring process by updating the code for the **Schedule** page. You will create a new class **ScheduleList**, and then you will move the existing functions and variables relating to the schedule list into this new class.
27
27
28
-
#### Task 1: Define the ScheduleList class.
28
+
#### Task 1: Define the ScheduleList class
29
29
30
-
1. Open the **ContosoConf.sln** solution in the **Allfiles\Mod07\Labfiles\Starter\Exercise 1** folder.
31
-
2. In the **schedule.js** file, in the **scripts\pages** folder, find & remove the following comment:
30
+
1. From the **Allfiles\Mod07\Labfiles\Starter\Exercise 1** folder, open the **ContosoConf.sln** solution.
31
+
2. In the **schedule.js** file, in the **scripts\pages** folder, find and remove the following comment:
32
32
```javascript
33
33
// TODO: Create a ScheduleList class.
34
34
```
35
-
3. In the **scripts** folder, add a new JavaScript File**ScheduleList.js**.
35
+
3. In the **scripts** folder, add a new JavaScript file**ScheduleList.js**.
36
36
37
-
#### Task 2: Convert variables into properties of the ScheduleList class.
38
-
1. Add a **constructor** to the **ScheduleList** class.
39
-
- The **constructor** should take two parameters called **element** and **localStarStorage**
40
-
- The **constructor** should use these two parameters to create and populate properties also called **element** and **localStarStorage** for the **ScheduleList** object
41
-
2. Remove the **element** and **localStarStorage** variables from the **ScheduleList** object (they have been moved to **ScheduleList** class).
37
+
#### Task 2: Convert variables into properties of the ScheduleList class
38
+
1. To the **ScheduleList** class, add a constructor.
39
+
- The constructor should take two parameters called **element** and **localStarStorage**.
40
+
- The constructor should use these two parameters to create and populate properties also called **element** and **localStarStorage** for the **ScheduleList** object.
41
+
2. Remove the **element** and **localStarStorage** variables from the **ScheduleList** object (they have been moved to the **ScheduleList** class).
42
42
43
-
#### Task 3: Convert functions into methods of the **ScheduleList** class.
43
+
#### Task 3: Convert functions into methods of the ScheduleList class
44
44
45
45
1. In the **schedule.js** file, find the following comment:
46
46
```javascript
47
47
// TODO: Refactor these functions into methods of the ScheduleList class.
48
48
```
49
49
2. Move each of the functions following the comment to **ScheduleList** class as methods.
50
50
51
-
>**Note:** As an example of refactoring a function, the following code:
52
-
> ```javascript
51
+
>**Note**: As an example of refactoring a function, the following code:
52
+
> ```javascript
53
53
>downloadDone:function (responseData) {
54
54
>addAll(responseData.schedule);
55
55
> }
56
-
>```
57
-
>Should be moved to the **ScheduleList** class as following method:
58
-
> ```javascript
56
+
>```
57
+
>Should be moved to the **ScheduleList** class as the following method:
58
+
> ```javascript
59
59
>downloadDone(responseData) {
60
60
>this.addAll(responseData.schedule);
61
61
> }
62
-
>```
62
+
>```
63
63
64
-
3. In the **startDownload** method, **downloadDone** and ***downloadFailed* method calls should be referenced by **this**.
64
+
3. In the **startDownload** method, **downloadDone** and **downloadFailed** method calls should be referenced by **this**.
65
65
66
66
67
67
4. In the **addAll** method, specify that the **forEach** function should call the **add** method of the object referenced by **this**. Also, pass **this** as the second parameter to the **forEach** function.
68
68
69
-
>**Note:** The second parameter to the **forEach** function specifies the object that any use of **this** will reference in the **add** function.
69
+
>**Note**: The second parameter to the **forEach** function specifies the object that any use of **this** will reference in the **add** function.
70
70
71
71
5. In the **add** method, **localStarStorage** and **element** should be referenced by **this**.
72
72
73
-
#### Task 4: Create and use a ScheduleList object.
73
+
#### Task 4: Create and use a ScheduleList object
74
74
75
75
1. Near the end of the **schedule.js** file, find the following JavaScript code:
76
76
```javascript
@@ -80,21 +80,21 @@ The JavaScript code for the Schedule page has been partially refactored to be mo
2. Modify this code to create a **ScheduleList** object by using the **newScheduleList()**constructor. Pass the DOM element and local star storage object as parameters to **new ScheduleList()**.
83
+
2. Modify this code to create a **ScheduleList** object by using the **newScheduleList()**constructor. Pass the DOM element and the **localStarStorage** object as parameters to **new ScheduleList()**.
84
84
3. Call the **startDownload** method of the **ScheduleList** object.
85
85
86
-
#### Task 5: Test the application.
86
+
#### Task 5: Test the application
87
87
88
-
1. Run the application and view the **schedule.htm** page.
88
+
1. Run the application, and then view the **schedule.htm** page.
89
89
2. Verify that the page looks similar to the image below:
90
90
91
91

92
92
93
-
>**Note:** The styling and layout of the Schedule page has been changed. This is performed by using the CSS rules implemented in the schedule.css style sheet and is not a result of any updates made to the JavaScript code.
93
+
>**Note**: The styling and layout of the **Schedule** page has been changed. This is performed by using the CSS rules implemented in the **schedule.css** style sheet and is not a result of any updates made to the JavaScript code.
94
94
95
95
3. Close Microsoft Edge.
96
96
97
-
>**Result:** After completing this exercise, you will be able to describe how the Contoso Conference application is structured as a Visual Studio 2017 project.
97
+
>**Result**: After completing this exercise, you will be able to describe how the Contoso Conference application is structured as a Microsoft Visual Studio 2017 project.
0 commit comments