Skip to content

Commit

Permalink
Cross-reference concept exercise file information (exercism#1320)
Browse files Browse the repository at this point in the history
[Docs] Cross-reference concept exercise file information
  • Loading branch information
ErikSchierboom committed Jan 26, 2021
1 parent 513e0a3 commit a57ca23
Showing 1 changed file with 70 additions and 18 deletions.
88 changes: 70 additions & 18 deletions reference/implementing-a-concept-exercise.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ As this document is generic, the following placeholders are used:

Before implementing the exercise, please make sure you have a good understanding of what the exercise should be teaching (and what not). This information can be found in the exercise's GitHub issue. Having done this, please read the [C# concept exercises introduction][concept-exercises].

To implement a concept exercise, the following files must be created:
To implement a concept exercise, the following files must be added:

<pre>
languages
Expand All @@ -28,11 +28,11 @@ languages
└── concept
└── &lt;SLUG&gt;
├── .docs
| ├── after.md
| ├── instructions.md
| ├── introduction.md
| ├── hints.md
| ├── source.md (required if there are third-party sources)
| └── after.md
| └── source.md (required if there are third-party sources)
├── .meta
| |── config.json
| |── design.md
Expand All @@ -42,32 +42,50 @@ languages
└── &lt;NAME&gt;Tests.cs
</pre>

## Step 1: adding track-specific files
## Step 1: Add code files

These files are specific to the C# track:
The code files are track-specific and should be designed to help the student learn the exercise's concepts. The following C# code files must be added (not necessarily in this order):

- `<NAME>.cs`. the stub implementation file, which is the starting point for students to work on the exercise.
- `<NAME>.csproj`: the C# project file.
- `<NAME>Tests.cs`: the test suite.
- `.meta/Example.cs`: an example implementation that passes all the tests.
### Add`<NAME>.cs` file

## Step 2: adding common files
**Purpose:** Provide a stub implementation.

How to create the files common to all tracks is described in the [how to implement a concept exercise document][how-to-implement-a-concept-exercise].
- The stub implementation's code should compile. The only exception is for exercises that introduce syntax we _want_ a student to define themselves, like how to define a class or property. In this case, insert a descriptive TODO comment instead of providing stub code (see [this example][todo]).
- Stub methods should throw a `NotImplementedException` which message contains the method to implement (see [this example][not-implemented]).

## Step 3: add analyzer (optional)
For more information, please read [this in-depth description][stub-file], [watch this video][video-stub-file] and check [this example stub file][example-stub-file].

Some exercises could benefit from having an exercise-specific [analyzer][analyzer]. If so, specify what analysis rules should be applied to this exercise and why.
### Add`<NAME>Tests.cs` file

Skip this step if you're not sure what to do.
**Purpose:** The test suite to verify a solution's correctness.

## Step 4: custom representation (optional)
- [xUnit][xunit] is used as the test framework.
- Only use `Fact` tests; don't use `Theory` tests.
- All but the first test should be skipped by default (check [this example][skip-fact]).

Some exercises could benefit from having an custom representation as generated by the [C# representer][representer]. If so, specify what changes to the representation should be applied and why.
For more information, please read [this in-depth description][tests-file], [watch this video][video-tests-file] and check [this example tests file][example-tests-file].

### Add`<NAME>.csproj` file

**Purpose:** The project file required to build the project and run the tests.

For more information, check [this example project file][example-project-file].

Skip this step if you're not sure what to do.
### Add`.meta/Example.cs` file

**Purpose:** The idiomatic example implementation that passes all the tests.

For more information, please read [this in-depth description][example-file], [watch this video][video-example-file] and check [this example file][example-example-file].

## Step 2: Add documentation files

How to create the files common to all tracks is described in the [how to implement a concept exercise document][how-to-implement-a-concept-exercise].

## Step 5: format code
## Step 3: Update list of implemented exercises

- Add the exercise to the [list of implemented exercises][implemented-exercises].

## Step 4: format code

All C# code should be formatted using the [`dotnet format` tool][dotnet-format]. There are two ways to format your C# code:

Expand All @@ -81,6 +99,18 @@ Open a command prompt in the `language/csharp` directory and then run:

- `./format.ps1 <SLUG>`, where `<SLUG>` is the exercise's directory name.

## Step 5: Add analyzer (optional)

Some exercises could benefit from having an exercise-specific [analyzer][analyzer]. If so, specify what analysis rules should be applied to this exercise and why.

_Skip this step if you're not sure what to do._

## Step 6: Add representation (optional)

Some exercises could benefit from having an custom representation as generated by the [C# representer][representer]. If so, specify what changes to the representation should be applied and why.

_Skip this step if you're not sure what to do._

## Inspiration

When implementing an exercise, it can be very useful to look at already implemented C# exercises like the [strings][concept-exercise-strings], [datetimes][concept-exercise-datetimes] or [floating-point numbers][concept-exercise-numbers-floating-point] exercises. You can also check the exercise's [general concepts documents][reference] to see if other languages have already implemented an exercise for that concept.
Expand All @@ -103,3 +133,25 @@ If you have any questions regarding implementing the exercise, please post them
[reference]: ../../../reference
[dotnet-format]: https://github.com/dotnet/format
[allowing-fork-pr-changes]: https://help.github.com/en/github/collaborating-with-issues-and-pull-requests/allowing-changes-to-a-pull-request-branch-created-from-a-fork
[implemented-exercises]: ../exercises/concept/README.md#implemented-exercises
[video-stub-file]: https://www.youtube.com/watch?v=gkbBqd7hPrA&t=1171
[video-tests-file]: https://www.youtube.com/watch?v=gkbBqd7hPrA&t=1255
[video-example-file]: https://www.youtube.com/watch?v=gkbBqd7hPrA&t=781
[example-stub-file]: ../exercises/concept/strings/Strings.cs
[example-tests-file]: ../exercises/concept/strings/StringsTests.cs
[example-example-file]: ../exercises/concept/strings/.meta/Example.cs
[example-project-file]: ../exercises/concept/strings/Strings.csproj
[skip-fact]: ../exercises/concept/strings/StringsTests.cs#L11
[xunit]: https://xunit.net/
[not-implemented]: ../exercises/concept/strings/Strings.cs#L5
[todo]: ../exercises/concept/basics/Basics.cs
[stub-file]: ../../../docs/concept-exercises.md#stub-implementation-file
[tests-file]: ../../../docs/concept-exercises.md#tests-file
[example-file]: ../../../docs/concept-exercises.md#example-implementation-file
[video-stub-file]: https://www.youtube.com/watch?v=gkbBqd7hPrA&t=1171
[video-tests-file]: https://www.youtube.com/watch?v=gkbBqd7hPrA&t=1255
[video-example-file]: https://www.youtube.com/watch?v=gkbBqd7hPrA&t=781
[example-stub-file]: ../languages/csharp/exercises/concept/strings/Strings.cs
[example-tests-file]: ../languages/csharp/exercises/concept/strings/StringsTests.cs
[example-example-file]: ../languages/csharp/exercises/concept/strings/.meta/Example.cs
[example-project-file]: ../exercises/concept/strings/Strings.csproj

0 comments on commit a57ca23

Please sign in to comment.