Skip to content

Commit 8d77213

Browse files
authored
Merge pull request #38 from VinayApposite/Apposite_20480C_Mod07_LM
Apposite 20480 c mod07 lm
2 parents 0c09c19 + dbf239d commit 8d77213

File tree

1 file changed

+27
-27
lines changed

1 file changed

+27
-27
lines changed

Instructions/20480C_MOD07_LAB_MANUAL.md

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
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.
88

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.
1010

1111
#### Objectives
1212

@@ -19,58 +19,58 @@ After completing this lab, you will be able to:
1919

2020
Estimated Time: **60 minutes**
2121

22-
### Exercise 1: Refactoring JavaScript Code to Use Classes and Objects.
22+
### Exercise 1: Refactoring JavaScript Code to Use Classes and Objects
2323

2424
#### Scenario
2525

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.
2727

28-
#### Task 1: Define the ScheduleList class.
28+
#### Task 1: Define the ScheduleList class
2929

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:
3232
```javascript
3333
// TODO: Create a ScheduleList class.
3434
```
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**.
3636

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).
4242

43-
#### Task 3: Convert functions into methods of the **ScheduleList** class.
43+
#### Task 3: Convert functions into methods of the ScheduleList class
4444

4545
1. In the **schedule.js** file, find the following comment:
4646
```javascript
4747
// TODO: Refactor these functions into methods of the ScheduleList class.
4848
```
4949
2. Move each of the functions following the comment to **ScheduleList** class as methods.
5050

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
5353
> downloadDone: function (responseData) {
5454
> addAll(responseData.schedule);
5555
> }
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
5959
> downloadDone(responseData) {
6060
> this.addAll(responseData.schedule);
6161
> }
62-
> ```
62+
> ```
6363
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**.
6565
6666
6767
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.
6868
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.
7070
7171
5. In the **add** method, **localStarStorage** and **element** should be referenced by **this**.
7272
73-
#### Task 4: Create and use a ScheduleList object.
73+
#### Task 4: Create and use a ScheduleList object
7474
7575
1. Near the end of the **schedule.js** file, find the following JavaScript code:
7676
```javascript
@@ -80,21 +80,21 @@ The JavaScript code for the Schedule page has been partially refactored to be mo
8080
localStarStorage = LocalStarStorage.create(localStorage);
8181
startDownload();
8282
```
83-
2. Modify this code to create a **ScheduleList** object by using the **new ScheduleList()** 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 **new ScheduleList()** constructor. Pass the DOM element and the **localStarStorage** object as parameters to **new ScheduleList()**.
8484
3. Call the **startDownload** method of the **ScheduleList** object.
8585
86-
#### Task 5: Test the application.
86+
#### Task 5: Test the application
8787
88-
1. Run the application and view the **schedule.htm** page.
88+
1. Run the application, and then view the **schedule.htm** page.
8989
2. Verify that the page looks similar to the image below:
9090
9191
![alt text](./Images/20480B_7_Schedule-Refactored.png "The Schedule page")
9292
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.
9494
9595
3. Close Microsoft Edge.
9696
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.
9898
9999
©2018 Microsoft Corporation. All rights reserved.
100100

0 commit comments

Comments
 (0)