This issue describes how to implement the nullability concept exercise for the C# track.
Getting started
Please please please read the docs before starting. Posting PRs without reading these docs will be a lot more frustrating for you during the review cycle, and exhaust Exercism's maintainers' time. So, before diving into the implementation, please read up on the following documents:
The goal of this exercise is to teach the student the basics of the Concept of Nullability in [C#].
Learning objectives
Know of the existence of the null literal.
Know what a NullReferenceException is and when it is thrown.
Know how to compare a value to null.
Know the difference between value and reference types regarding nullability, especially pre C# 8.0.
Know how to define nullable reference and value types.
Know about the null-related operators (!, ?, ??).
Know about basic null checking by the compiler.
Out of scope
Nullable attributes.
In-depth discussion of null checking by the compiler.
Enabling C# 8 null checking.
Casting using the as or is operator or using pattern matching.
Concepts
This Concepts Exercise's Concepts are:
nullability: know of the existence of the null literal; know what a NullReferenceException is and when it is thrown; know how to compare a value to null; know the difference between value and reference types regarding nullability; know how to define nullable reference and value types; know about the null-related operators; know about basic null checking by the compiler.
Prequisites
This Concept Exercise's prerequisites Concepts are:
strings: strings will be compared to null.
basics: integers will be compared to null and variables will be introduced and updated..
exceptions: explain how a NullReferenceException is thrown when accessing a null value.
Resources to refer to
Hints
Null keyword: reference documentation for null keyword.
This exercise does not require any specific representation logic to be added to the representer.
Analyzer
This exercise does not require any specific analyzer logic to be added to the analyzer.
Implementing
If you'd like to work on implementing this exercise, the first step is to let us know through a comment on this issue, to prevent multiple people from working on the same exercise. If you have any questions while implementing the exercise, please also post them as comments in this issue.
Implementing the exercise means creating the following files:
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.
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.
Step 2: add .docs/instructions.md
This file contains instructions for the exercise. It should explicitly explain what the student needs to do (define a method with the signature X(...) 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.
Step 3: add .docs/hints.md
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.
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.
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).
Step 4: add .docs/after.md
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.
This file contains information on the exercise's design, which includes things like its goal, its teaching goals, what not to teach, and more (example). This information can be extracted from this GitHub issue.
Step 10: add .meta/config.json:
This file contains meta information on the exercise, which currently only includes the exercise's contributors (example).
This issue describes how to implement the
nullability
concept exercise for the C# track.Getting started
Please please please read the docs before starting. Posting PRs without reading these docs will be a lot more frustrating for you during the review cycle, and exhaust Exercism's maintainers' time. So, before diving into the implementation, please read up on the following documents:
Please also watch the following video:
Goal
The goal of this exercise is to teach the student the basics of the Concept of Nullability in [C#].
Learning objectives
null
literal.NullReferenceException
is and when it is thrown.null
.!
,?
,??
).Out of scope
as
oris
operator or using pattern matching.Concepts
This Concepts Exercise's Concepts are:
nullability
: know of the existence of thenull
literal; know what aNullReferenceException
is and when it is thrown; know how to compare a value tonull
; know the difference between value and reference types regarding nullability; know how to define nullable reference and value types; know about the null-related operators; know about basic null checking by the compiler.Prequisites
This Concept Exercise's prerequisites Concepts are:
strings
: strings will be compared tonull
.basics
: integers will be compared tonull
and variables will be introduced and updated..exceptions
: explain how aNullReferenceException
is thrown when accessing anull
value.Resources to refer to
Hints
null
keyword.After
null
keyword.Representer
This exercise does not require any specific representation logic to be added to the representer.
Analyzer
This exercise does not require any specific analyzer logic to be added to the analyzer.
Implementing
If you'd like to work on implementing this exercise, the first step is to let us know through a comment on this issue, to prevent multiple people from working on the same exercise. If you have any questions while implementing the exercise, please also post them as comments in this issue.
Implementing the exercise means creating the following files:
Step 1: add .docs/introduction.md
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.
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.
Step 2: add .docs/instructions.md
This file contains instructions for the exercise. It should explicitly explain what the student needs to do (define a method with the signature
X(...)
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.Step 3: add .docs/hints.md
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.
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.
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).
Step 4: add .docs/after.md
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.
The above four files are also all described in the concept exercises document.
Step 5: update languages/csharp/config.json
An entry should be added to the track's
config.json
file for the new concept exercise:Step 6: adding track-specific files
These files are specific to the C# track:
Nullability.csproj
: the C# project file. Note: the C# 8 nullabillity checking should be enabled.NullabilityTests.cs
: the test suite.Nullability.cs
. the stub implementation file, which is the starting point for students to work on the exercise..meta/Example.cs
: an example implementation that passes all the tests.Check out an existing exercise to see what these files should look like.
Step 7: update the general concept document
Add the exercise to the concept's shared document's
## Implementations
section (example).Step 8: updating char of implemented exercises
Step 9: add .meta/design.md:
This file contains information on the exercise's design, which includes things like its goal, its teaching goals, what not to teach, and more (example). This information can be extracted from this GitHub issue.
Step 10: add .meta/config.json:
This file contains meta information on the exercise, which currently only includes the exercise's contributors (example).
Inspiration
When implementing this exericse, it can be very useful to look at already implemented C# exercises. You can also check the general char concept documentation to see if any other languages have already implemented a nullability exercise.