-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #25 from neu-se/module06-async
module06 - async
- Loading branch information
Showing
8 changed files
with
116 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
--- | ||
layout: page | ||
title: Async Activity | ||
nav_exclude: true | ||
--- | ||
|
||
# Simple Activity using async/await | ||
|
||
Learning Objectives for this activity: | ||
* Practice applying asynchronous programming concepts: promises, async/await | ||
* Experiment with applying different ordering constraints in asynchronous code | ||
|
||
## Overview | ||
In this activity, you will experiment with asynchronous programming constructs in TypeScript. | ||
|
||
### Getting started | ||
Download [starter Code]({{ site.baseurl }}{% link Activities/module06-async_activity.zip %}) | ||
Run `npm install` to download the dependencies for this project, and then open it in your IDE of choice. | ||
Run `npm run client` to run the client as-is, the output should be something like: | ||
|
||
``` | ||
Creating a student | ||
Import grades completed, and returned: | ||
[ | ||
{ | ||
"student": { | ||
"studentID": 17, | ||
"studentName": "test student" | ||
}, | ||
"grades": [ | ||
{ | ||
"course": "demo course", | ||
"grade": 100 | ||
} | ||
] | ||
} | ||
] | ||
``` | ||
|
||
### Stringing together many async calls: bulk importing grades | ||
Your task is to write a new, `async` function, `importGrades`, which takes in input of the type `ImportTranscript[]`. | ||
`importGrades` should create a student record for each `ImportTranscript`, and then post the grades for each of those students. | ||
After posting the grades, it should fetch the transcripts for each student and return an array of transcripts. | ||
|
||
You should implement `importGrades` in the file `examples.ts` - note that there is already a function stub there. | ||
As you get started, examine the transcript server client in `client.ts`, and take note of the API calls that are available to you. | ||
|
||
Here is the type definition for `ImportTranscript` and its dependencies: | ||
``` | ||
type ImportTranscript = { | ||
studentName: string; | ||
grades: CourseGrade[]; | ||
}; | ||
type CourseGrade = { course: Course, grade: number }; | ||
type Course = string; | ||
``` | ||
|
||
Example input: | ||
``` | ||
[ | ||
{ | ||
studentName: "Avery", | ||
grades: [{course: "Software Engineering", grade: 100}, {course: "Chemistry", grade: 70}], | ||
}, | ||
{ | ||
studentName: "Ripley", | ||
grades: [{course: "Underwater Basket Weaving", grade: 100}, {course: "Kayaking", grade: 90} ] | ||
} | ||
] | ||
``` | ||
|
||
Implement this three ways: | ||
1. Insert a student, insert each of their grades (in order), then insert the next student, then their grades, etc. until all students are inserted, then fetch transcripts | ||
2. Insert a student, then insert each of their grades (in order), then fetch their transcript. Do this set of operations asynchronously (concurrently) for all students | ||
3. Insert a student, then insert each of their grades asynchronously (concurrently). After all students have all of their grades submitted, fetch all fo the transcripts asynchronously (concurrently) |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
--- | ||
title: Team Formation Survey is Now Available | ||
week: 4 | ||
date: 2024-01-23 | ||
--- | ||
Please complete this [Team Formation Survey](https://northeastern.instructure.com/courses/166618/assignments/2184900) to help us organize you into a team for the term project. EVERY STUDENT must fill this form out by 11am on Wednesday 1/31/2024, or risk being placed in a random team. | ||
|
||
{: .fs-5 } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
--- | ||
layout: module | ||
title: "6 - Concurrency Patterns in Typescript" | ||
permalink: /modules/6-concurrency-patterns-in-typescript | ||
parent: Modules | ||
nav_order: 6 | ||
lessons: | ||
- title: "Concurrency Patterns in Typescript" | ||
ppt: "Module 06 Concurrency Patterns in Typescript.pptx" | ||
pdf: "Module 06 Concurrency Patterns in Typescript.pdf" | ||
|
||
--- | ||
### Learning Objectives: | ||
A 1 GHz CPU executes an instruction every 1 ns. Almost anything else takes approximately forever. Rather than waste time waiting for a long-running operation to complete, we want our programs to make progress on other tasks. This is called "masking latency with concurrency". | ||
|
||
In this lecture, we will study some common patterns for organizing concurrency in Typescript/Javascript. | ||
|
||
By the end of this lesson, you should be prepared to: | ||
* Explain the difference between JS run-to-completion semantics and interrupt-based semantics. | ||
* Given a simple program using async/await, work out the order in which the statements in the program will run. | ||
* Write simple programs that create and manage promises using async/await | ||
* Write simple programs to mask latency with concurrency by using non-blocking IO and Promise.all in TypeScript. | ||
|
||
|
||
{% include lesson.html %} | ||
|
||
### Activities: | ||
* [Async Activity]({{ site.baseurl }}{% link Activities/Module06 Activity.md %}) | ||
|
||
### Resources | ||
* [Code Examples from Slides]({{ site.baseurl }}{% link Examples/module-06-async-examples.zip %}) |