Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create mentoring.md #2309

Merged
merged 4 commits into from
Feb 2, 2024
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
87 changes: 87 additions & 0 deletions tracks/typescript/exercises/etl/etl/mentoring.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
# Mentoring

## ETL

### Problem asks

Restructure grouped letters by point values into individual mappings.
Transform the old format (point-value groups) into a new format (letter-score pairs) in TypeScript.
Associate lowercase letters with their corresponding point values, transitioning from grouped data to individual letter scoring.

## Reasonable Solution

The code snippet provided in TypeScript represents a function named transform.
SleeplessByte marked this conversation as resolved.
Show resolved Hide resolved
This function takes in an object oldData, which has keys representing point values (as strings) and values as arrays of strings (letters associated with those point values).
SleeplessByte marked this conversation as resolved.
Show resolved Hide resolved

The function iterates through the oldData object, assigning each letter (converted to lowercase) to its corresponding score in the newData object.
SleeplessByte marked this conversation as resolved.
Show resolved Hide resolved
The return value of the function is an object where keys are lowercase letters and values are the associated point values (as numbers).

```typescript
export function transform(oldData: { [key: string]: string[] }): { [key: string]: number } {
const newData: { [key: string]: number } = {};

for (const [score, letters] of Object.entries(oldData)) {
letters.forEach((letter: string) => {
newData[letter.toLowerCase()] = parseInt(score);
});
}

return newData;
}
```

Certainly! Here's a mentoring file for the ETL (Extract, Transform, Load) problem based on the structure of the previous mentoring file for the leap year problem:

```markdown
# Mentoring

## ETL

### Problem Overview

The ETL problem involves transforming data from an old format to a new format. In this case, the task is to restructure grouped letters by point values into individual mappings. The old format consists of point-value groups, while the new format should be letter-score pairs.

### Reasonable Solution

The provided TypeScript code represents a function named `transform`. This function takes in an object `oldData`, where keys represent point values (as strings) and values are arrays of strings (letters associated with those point values).

The function iterates through the `oldData` object, assigning each letter (converted to lowercase) to its corresponding score in the `newData` object. The return value of the function is an object where keys are lowercase letters, and values are the associated point values (as numbers).

```typescript
export function transform(oldData: { [key: string]: string[] }): { [key: string]: number } {
const newData: { [key: string]: number } = {};

for (const [score, letters] of Object.entries(oldData)) {
letters.forEach((letter: string) => {
newData[letter.toLowerCase()] = Number(score);
});
}

return newData;
}
```
RomaLetodiani marked this conversation as resolved.
Show resolved Hide resolved
SleeplessByte marked this conversation as resolved.
Show resolved Hide resolved

### Common Suggestions:

1. **Type Annotations:**
- Encourage the use of explicit type annotations for parameters and return values to enhance code readability and maintainability.

```typescript
export function transform(oldData: { [key: string]: string[] }): { [key: string]: number } {
```

2. **Data Validation:**
- Discuss potential edge cases or invalid data scenarios. What happens if the input data is malformed or if a letter is associated with multiple scores?

### Talking Points:

- **ETL Concept:**
- Briefly explain the ETL concept, emphasizing its role in transforming data from one format to another.

- **Type Safety:**
- Emphasize the use of TypeScript for type safety. Ensure that the input and output types are clearly defined to catch potential runtime errors.

- **Functional Approach:**
- Introduce a more functional approach using methods like `map` and `reduce` for constructing the new data object, making the code more concise.

This mentoring file aims to guide students through understanding the ETL problem, providing a reasonable solution, and offering suggestions for improvement and further exploration.
SleeplessByte marked this conversation as resolved.
Show resolved Hide resolved
Loading