Skip to content

Commit

Permalink
ensure that all basics concepts are mentioned in about.md and files a…
Browse files Browse the repository at this point in the history
…re consistent

manual construction of about.md to avoid merge conflicts

* basics ensure all concepts identified for the basics story are included

* basics ensure all concepts identified for the basics story are included

* basics ensure all concepts identified for the basics story are included in about.md but as sub-concepts for basics

* basics better link for functions

* basics address review points

* [CI] Format code

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
  • Loading branch information
2 people authored and ErikSchierboom committed Feb 2, 2021
1 parent d6e1ff2 commit 567dd9a
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 62 deletions.
12 changes: 9 additions & 3 deletions concepts/basics/about.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
C# is a statically-typed language, which means that everything has a type at compile-time. Choosing a name for a variable is referred to as defining a variable. Once a variable is defined, setting or updating a value is called variable assignment. A variable can be defined either by explicitly specifying its type, or by using the [`var` keyword][var] to have the C# compiler infer its type based on the assigned value.
C# is a statically-typed language, which means that everything has a type at compile-time. Choosing a name for a [variable][variable] is referred to as defining a variable. Once a variable is defined, setting or updating a value is called variable assignment. A variable can be defined either by explicitly specifying its type, or by using the [`var` keyword][var] to have the C# compiler infer its type based on the assigned value. The use of `var` is known as _type inference_.

```csharp
int explicitVar = 10; // Explicitly typed
Expand All @@ -15,7 +15,7 @@ count = 2; // Update to new value
// count = false;
```

C# is an object-oriented language and requires all functions to be defined in a _class_, which are defined using the [`class` keyword][classes]. Objects (or _instances_) are created by using the `new` keyword.
C# is an object-oriented language and requires all [functions][function] to be defined in a _class_, which are defined using the [`class` keyword][classes]. Objects (or _instances_) are created by using the `new` keyword.

```csharp
class Calculator
Expand Down Expand Up @@ -70,7 +70,9 @@ C# supports two types of [comments][comments]. Single line comments are preceded

Integer values are defined as one or more (consecutive) digits and support the [default mathematical operators][operators].

A variable name [must follow some rules][identifier-names] like starting either by a letter or an underscore, and [should follow C# naming convention][naming-guidelines]. If a variable name collides with a reserved [C# keyword][csharp-keywords], it must be escaped using `@`. It is not recommended to use that notation, but it can be encountered in exceptional cases, for example: `var @this`, `var @class` or `var @var`.
A variable name [must follow some rules][identifier-names] like starting either by a letter or an underscore, and [should follow C# naming convention][naming-guidelines]. If a variable name collides with a reserved [C# keyword][csharp-keywords], it must be escaped using `@`. Use of that notation is not recommended, but it can be encountered in exceptional cases, for example: `var @this`, `var @class` or `var @var`.

There are a couple of concepts that are so fundamental to a C-family language like C# that they occur naturally in almost any piece of non-trivial code. These are [mutation][mutation] and [scope][scope]. Mutation is the idea that a variable can have its value changed in the course of a program's lifetime. Scope is the idea that the value associated with a name (of a program element) is only accessible within the code "area" where it is defined. The principal code areas in C# are _class/struct_ and _function_ (typically methods) but can also include the bodies of loops and other constructs.

[assignment]: https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/operators/assignment-operator
[var]: https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/var
Expand All @@ -82,3 +84,7 @@ A variable name [must follow some rules][identifier-names] like starting either
[identifier-names]: https://docs.microsoft.com/en-us/dotnet/csharp/programming-guide/inside-a-program/identifier-names
[naming-guidelines]: https://docs.microsoft.com/en-us/dotnet/standard/design-guidelines/naming-guidelines
[csharp-keywords]: https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/
[variable]: https://www.guru99.com/c-sharp-variables-operator.html
[function]: https://csharp.net-tutorials.com/classes/methods/
[mutation]: https://benmccormick.org/2016/06/04/what-are-mutable-and-immutable-data-structures-2
[scope]: https://www.geeksforgeeks.org/scope-of-variables-in-c-sharp/
13 changes: 3 additions & 10 deletions exercises/concept/lucians-luscious-lasagna/.meta/design.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
- Know how to call a method
- Know that methods must be defined in classes
- Know about the `public` access modifier
- Know about the `static` modifier (only in concept's `about.md`)
- Know about the `static` modifier (only in the concept's `about.md`)
- Know how to define an integer
- Know how to use mathematical operators on integers
- Know how to define single- and multiline comments
Expand All @@ -30,22 +30,15 @@

## Concepts

- `basics`: know what a variable is; know how to define a variable; know how to update a variable; know how to use type inference for variables; know how to define a method; know how to return a value from a method; know how to call a method; know that methods must be defined in classes; know about the `public` access modifier; know about the `static` modifier; know how to define an integer; know how to use mathematical operators on integers; know how to define single- and multiline comments.
- `type-inference`: know how to use the keyword, `var`; know when it is appropriate to use type-inference
- `return-values`: know the syntax of the return statement
- `mutation`: know how OO state is maintained and updated in C#
- `functions`: know the syntax of a function call; know the syntax of a function declaration; understand the role of functions within OO
- `comments`: know the syntax of a single line comment; know the syntax of a multi-line comment
- `scoping`: know how scope works, what is in scope and out of scope at any point in the code
- `variables`: know how to declare a variable; know how to use a variable
- `basics`: know what a variable is; know how to define a variable; know how to update a variable; know how to use type inference for variables; know how to define a method; know how to return a value from a method; know how to call a method; know that methods must be defined in classes; know about the `public` access modifier; know about the `static` modifier; know how to define an integer; know how to use mathematical operators on integers; know how to define single- and multiline comments. The following sub-concepts are included `type-inference`, `return-values`, `mutation`, `functions`, `comments`, `scoping`, `variables`

## Prerequisites

There are no prerequisites.

## Analyzer

This exercise could benefit from the following rules added to the the [analyzer][analyzer]:
This exercise could benefit from the following rules added to the [analyzer][analyzer]:

- Verify that the `RemainingMinutesInOven()` method calls the `ExpectedMinutesInOven()` method.
- Verify that the `ElapsedTimeInMinutes()` method calls the `PreparationTimeInMinutes()` method.
Expand Down
56 changes: 7 additions & 49 deletions reference/exercises.json
Original file line number Diff line number Diff line change
Expand Up @@ -88,73 +88,31 @@
{
"name": " basics (including methods)",
"line-number": 20
}
]
},
{
"name": "return-values",
"track-neutral-concept": "",
"original-concepts": [
},
{
"name": " - Return values",
"line-number": 30
}
]
},
{
"name": "mutation",
"track-neutral-concept": "reference/concepts/mutation.md",
"original-concepts": [
},
{
"name": "- [Mutation][mutation]",
"line-number": 31
}
]
},
{
"name": "functions",
"track-neutral-concept": "reference/types/function.md",
"original-concepts": [
},
{
"name": "- [Functions][functions]",
"line-number": 46
}
]
},
{
"name": "type-inference",
"track-neutral-concept": "reference/concepts/type_inference.md",
"original-concepts": [
},
{
"name": "- [Type inference][type_inference]",
"line-number": 61
}
]
},
{
"name": "comments",
"track-neutral-concept": "",
"original-concepts": [
},
{
"name": "- Comments",
"line-number": 78
}
]
},
{
"name": "scoping",
"track-neutral-concept": "",
"original-concepts": [
},
{
"name": "- Scoping",
"line-number": 120
}
]
},
{
"name": "variables",
"track-neutral-concept": "reference/concepts/variables.md",
"original-concepts": [
},
{
"name": "- [Variables][variables]",
"line-number": 131
Expand Down

0 comments on commit 567dd9a

Please sign in to comment.