Skip to content

Commit c2bbba5

Browse files
Add approaches docs (#431)
1 parent 6a0731f commit c2bbba5

File tree

1 file changed

+138
-1
lines changed

1 file changed

+138
-1
lines changed

building/tracks/practice-exercises.md

Lines changed: 138 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,144 @@ Note that:
312312
- The order of authors and contributors is not significant and has no meaning.
313313
- `language_versions` is a free-form string that tracks are free to use and interpret as they like.
314314

315-
the articles
315+
### File: `.approaches/introduction.md`
316+
317+
**Purpose:** Introduction to the most common approaches for the exercise
318+
319+
**Presence:** Optional
320+
321+
This file describes the most common approaches for the exercise.
322+
Check the [documentation](/docs/building/tracks/approaches) for more information on what should go in this file.
323+
324+
#### Example
325+
326+
````markdown
327+
# Introduction
328+
329+
The key to this exercise is to deal with C# strings being immutable, which means that a `string`'s value cannot be changed.
330+
Therefore, to reverse a string you'll need to create a _new_ `string`.
331+
332+
## Using LINQ
333+
334+
```csharp
335+
public static string Reverse(string input)
336+
{
337+
return new string(input.Reverse().ToArray());
338+
}
339+
```
340+
341+
For more information, check the [LINQ approach][approach-linq].
342+
343+
## Which approach to use?
344+
345+
If readability is your primary concern (and it usually should be), the LINQ-based approach is hard to beat.
346+
````
347+
348+
---
349+
350+
### File: `.approaches/config.json`
351+
352+
**Purpose:** Metadata for the approaches
353+
354+
**Presence:** Optional (required when an approach introduction or approach exists)
355+
356+
This file contains meta information on the exercise's approaches:
357+
358+
- `introduction`: The GitHub username(s) of the exercise approach introduction's author(s) (optional)
359+
360+
- `authors`: The GitHub username(s) of the exercise approach introduction's author(s) (required)
361+
- Including reviewers if their reviews substantially change the exercise approach introduction (to the extent where it feels like "you got there together")
362+
- `contributors`: The GitHub username(s) of the exercise approach introduction's contributor(s) (optional)
363+
- Including reviewers if their reviews are meaningful/actionable/actioned.
364+
365+
- `approaches`: An array listing the detailed approaches (optional)
366+
- `uuid`: a V4 UUID that uniquely identifies the approach. The UUID must be unique both within the track as well as across all tracks, and must never change
367+
- `slug`: the approach's slug, which is a lowercased, kebab-case string. The slug must be unique across all approach slugs within the track. Its length must be <= 255.
368+
- `title`: the approach's title. Its length must be <= 255.
369+
- `blurb`: A short description of this approach. Its length must be <= 350. Markdown is _not_ supported (required)
370+
- `authors`: The GitHub username(s) of the exercise approach's author(s) (required)
371+
- Including reviewers if their reviews substantially change the exercise approach (to the extent where it feels like "you got there together")
372+
- `contributors`: The GitHub username(s) of the exercise approach's contributor(s) (optional)
373+
- Including reviewers if their reviews are meaningful/actionable/actioned.
374+
375+
#### Example
376+
377+
```json
378+
{
379+
"introduction": {
380+
"authors": ["erikschierboom"]
381+
},
382+
"approaches": [
383+
{
384+
"uuid": "448fb2b4-18ab-4e55-aa54-ad4ed6d5f7f6",
385+
"slug": "span",
386+
"title": "Use Span<T>",
387+
"blurb": "Use Span<T> to efficiently reverse a string.",
388+
"authors": ["erikschierboom"]
389+
}
390+
]
391+
}
392+
```
393+
394+
---
395+
396+
### File: `.approaches/<approach-slug>/content.md`
397+
398+
**Purpose:** Detailed description of the approach
399+
400+
**Presence:** Optional (required for approaches)
401+
402+
This file contains a detailed description of the approach.
403+
Check the [documentation](/docs/building/tracks/approaches) for more information on what should go in this file.
404+
405+
#### Example
406+
407+
````markdown
408+
# Span
409+
410+
```csharp
411+
Span<char> chars = stackalloc char[input.Length];
412+
for (var i = 0; i < input.Length; i++)
413+
{
414+
chars[input.Length - 1 - i] = input[i];
415+
}
416+
return new string(chars);
417+
```
418+
419+
This `Span<T>` approach uses a `for` loop.
420+
````
421+
422+
---
423+
424+
### File: `.approaches/<approach-slug>/snippet.txt`
425+
426+
**Purpose:** Snippet showcasing the approach
427+
428+
**Presence:** Optional (required for approaches)
429+
430+
This file contains a small snippet that showcases the approach.
431+
The snippet is shown on an exercise's dig deeper page.
432+
433+
Its number of lines must be <= 8.
434+
435+
Check the [documentation](/docs/building/tracks/approaches) for more information on what should go in this file.
436+
437+
#### Example
438+
439+
```csharp
440+
Span<char> chars = stackalloc char[input.Length];
441+
for (var i = 0; i < input.Length; i++)
442+
{
443+
chars[input.Length - 1 - i] = input[i];
444+
}
445+
return new string(chars);
446+
```
447+
448+
---
449+
450+
### File: `.article/config.json`
451+
452+
**Purpose:** Metadata for the articles
316453

317454
**Presence:** Optional (required when an article exists)
318455

0 commit comments

Comments
 (0)