|
1 | | -# How to implement an Java concept exercise |
| 1 | +# How to implement a Java Concept Exercise |
2 | 2 |
|
3 | | -TODO: describe how to implement a concept exercise for the Java track. For inspiration, check out the [C# version of this file][csharp-implementing]. |
| 3 | +This document describes how to implement a Concept Exercise for the Java track. As this document is generic, the following placeholders are used: |
4 | 4 |
|
5 | | -[csharp-implementing]: ../../csharp/reference/implementing-a-concept-exercise.md |
| 5 | +- `<slug>`: the name of the exercise in snake_case (e.g. `anonymous-methods`). |
| 6 | +- `<concepts>`: the Concepts the exercise is about (e.g. `loops`), |
| 7 | +- `<concept-1>`: a single Concept slug, |
| 8 | +- `<prerequisite-n>`: a single Concept slug, |
| 9 | +- `<uuid>`: a _new_ v4 UUID (random!) |
| 10 | +- `<first-and-last-name>`: your first and last name (e.g. `John Doe`) |
| 11 | +- `<git-email>`: the email address you use for git (e.g. `johndoe@email.com`) |
| 12 | + |
| 13 | +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 [Java Concept exercises introduction][concept-exercises]. If you have come up with something completely new, create a new issue _first_ so we can discuss the Concept Exercise. |
| 14 | + |
| 15 | +To implement a Concept Exercise, the following files must be created: |
| 16 | + |
| 17 | +<pre> |
| 18 | +languages |
| 19 | +└── java |
| 20 | + └── exercises |
| 21 | + └── concept |
| 22 | + └── <slug> |
| 23 | + |── .docs |
| 24 | + | |── instructions.md |
| 25 | + | |── introduction.md |
| 26 | + | |── hints.md |
| 27 | + | └── after.md (optional) |
| 28 | + |── .gitignore |
| 29 | + |── .meta |
| 30 | + | |── design.md |
| 31 | + | |── config.json |
| 32 | + | └── example |
| 33 | + | |── build.gradle |
| 34 | + | └── src |
| 35 | + | └── main |
| 36 | + | └── java |
| 37 | + | └── <slug>.java |
| 38 | + |── build.gradle |
| 39 | + └── src |
| 40 | + |── main |
| 41 | + | └── java |
| 42 | + | └── <slug>.java |
| 43 | + └── test |
| 44 | + └── java |
| 45 | + └── <slug>Test.java |
| 46 | +</pre> |
| 47 | + |
| 48 | +## Step 1: add .docs/introduction.md |
| 49 | + |
| 50 | +This file contains an introduction to the concept. It should make the exercise's learning goals explicit and provide a short introduction with enough detail for the student to complete the exercise. The aim is to give the student just enough context to figure out the solution themselves, as research has shown that self-discovery is the most effective learning experience. Using the proper technical terms in the descriptions will be helpful if the student wants to search for more information. If the exercise introduces new syntax, an example of the syntax should always be included; students should not need to search the web for examples of syntax. |
| 51 | + |
| 52 | +As an example, the introduction to a "strings" exercise might describe a string as just a "Sequence of Unicode characters" or a "series of bytes". Unless the student needs to understand more nuanced details in order to solve the exercise, this type of brief explanation (along with an example of its syntax) should be sufficient information for the student to solve the exercise. |
| 53 | + |
| 54 | +## Step 2: add .docs/instructions.md |
| 55 | + |
| 56 | +This file contains instructions for the exercise. It should explicitly explain what the student needs to do (define a method with the signature `public String X(String s)` that takes an A and returns a Z), and provide at least one example usage of that function. If there are multiple tasks within the exercise, it should provide an example of each. |
| 57 | + |
| 58 | +## Step 3: add .docs/hints.md |
| 59 | + |
| 60 | +If the student gets stuck, we will allow them to click a button requesting a hint, which shows this file. This will not be a "recommended" path and we will (softly) discourage them using it unless they can't progress without it. As such, it's worth considering that the student reading it will be a little confused/overwhelmed and maybe frustrated. |
| 61 | + |
| 62 | +The file should contain both general and task-specific "hints". These hints should be enough to unblock almost any student. They might link to the docs of the functions that need to be used. |
| 63 | + |
| 64 | +The hints should not spell out the solution, but instead point to a resource describing the solution (e.g. linking to documentation for the function to use). |
| 65 | + |
| 66 | +## Step 4: add .docs/after.md |
| 67 | + |
| 68 | +Once the student completes the exercise they will be shown this file, which should provide them with a summary of what the exercise aimed to teach. This document can also link to any additional resources that might be interesting to the student in the context of the exercise. |
| 69 | + |
| 70 | +## Step 5: update languages/java/config.json |
| 71 | + |
| 72 | +An entry should be added to the track's `config.json` file for the new Concept Exercise: |
| 73 | + |
| 74 | +```json |
| 75 | +{ |
| 76 | + ... |
| 77 | + "exercises": { |
| 78 | + "concept": [ |
| 79 | + ... |
| 80 | + { |
| 81 | + "slug": "<slug>", |
| 82 | + "uuid": "<uuid>", |
| 83 | + "concepts": ["<concept-1>"], |
| 84 | + "prerequisites": ["<prerequisite-1>", "<prerequisite-2>"] |
| 85 | + } |
| 86 | + ] |
| 87 | + } |
| 88 | +} |
| 89 | +``` |
| 90 | + |
| 91 | +## Step 6: adding track-specific files |
| 92 | + |
| 93 | +The configuration files may be copied from another exercise. We aim to keep these in sync: |
| 94 | + |
| 95 | +- `build.gradle` |
| 96 | + |
| 97 | +Now create the following three files: |
| 98 | + |
| 99 | +- `src/main/java/<slug>.java`. the stub implementation file, which is the starting point for students to work on the exercise. |
| 100 | +- `src/test/java/<slug>Test.java`: the test suite. |
| 101 | +- `.meta/example/src/main/java/<slug>.java`: an example implementation that passes all the tests. |
| 102 | + |
| 103 | +## Step 7: add analyzer (optional) |
| 104 | + |
| 105 | +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. |
| 106 | + |
| 107 | +## Step 8: custom representation (optional) |
| 108 | + |
| 109 | +Some exercises could benefit from having an custom representation as generated by the [Java representer][representer]. If so, specify what changes to the representation should be applied and why. |
| 110 | + |
| 111 | +## Step 9: add `.meta/design.md` |
| 112 | + |
| 113 | +This file contains information on the exercise's design, which includes things like its goal, its teaching goals, what not to teach, and more. This information can be extracted from the exercise's corresponding GitHub issue. |
| 114 | + |
| 115 | +## Step 10: add .meta/config.json: |
| 116 | + |
| 117 | +This file contains meta information on the exercise, which currently only includes the exercise's contributors. |
| 118 | + |
| 119 | +## Inspiration |
| 120 | + |
| 121 | +When implementing an exercise, it can be very useful to look at the exercises the track has already implemented. You can also check the exercise's [general concepts documents][reference] to see if other languages that have already an exercise for that Concept. |
| 122 | + |
| 123 | +## Inspiration |
| 124 | + |
| 125 | +When implementing an exercise, it can be very useful to look at already implemented Java exercises like the strings or numbers 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. |
| 126 | + |
| 127 | +## Help |
| 128 | + |
| 129 | +If you have any questions regarding implementing the exercise, please post them as comments in the exercise's GitHub issue. |
| 130 | + |
| 131 | +[analyzer]: https://github.com/exercism/java-analyzer |
| 132 | +[representer]: https://github.com/exercism/java-representer |
| 133 | +[concept-exercises]: ../exercises/concept/README.md |
| 134 | +[how-to-implement-a-concept-exercise]: ../../../docs/maintainers/generic-how-to-implement-a-concept-exercise.md |
| 135 | +[reference]: ../../../reference/README.md |
0 commit comments