[Epic] Proposed Everyday C# TOC
- Dominant language
- No language data
- Stars
- 4.8k
- Forks
- 6.1k
- Avg merge
- 15h 21m
- Merged PRs (30d)
- 370
Description
The following is an outline of the Everyday C# curriculum. It is not a complete syllabus. It has enough of an abstract for each section to begin writing that section.
1. **Intro / hello world**: This section ensures that the reader has the correct tools installed, and can build and run applications locally. This section will use zone pivots to make it easier for readers on different operating systems. We'll gently Visual Studio on both PC and Mac, and VS Code on Linux. If developers prefer VS Code, they can use that pivot.
- *Objective*: The developer has installed necessary tools, built their first local application, and explored some C# syntax.
1. **Algorithms**: This section focuses on the elements of the C# language that developers use when they write the implementation of any method, local function, or property / indexer accessor. This section is the most changed by updating the "inner loop" coding tasks to use newer features. The techniques covered, and the samples will focus on using the latest features to write the most concise, readable code.
- *Objective*: The developer feels comfortable writing code that implements their algorithms. It may not be the most performant, but is readable, and generally correct.
The modules include:
1. `string type`, and string interpolation.
1. Numeric types, with a focus on `int`, and `double`.
1. Working with collections, ranges and indexes. The samples will use Arrays , `List`, and `Dictionary`. Arrays will be limited to single-dimensional arrays. This module will include using index and range types to access elements and slices of collections. This will include loops to enumerate sequences (`foreach`, `while`, `for` and `do` - `while`).
1. Imperative branching (`if`, `else`, `switch`)
1. Query expressions and LINQ. Cover query syntax, fluent syntax, enumerating and transforming sequences. Lambda expressions are introduced here.
1. lambda expressions for callbacks and events: Introduce the concept of callbacks, raising events, and the syntax behind those concepts. Lambdas were introduced with LINQ. This module will expand on those uses.
1. Pattern matching. Introduce pattern matching as a way to write expression- based logic over imperative branching. This won't exhaustively cover all patterns, but instead provide several examples for type checking, property checking, and list patterns.
1. `async` methods, `await`ing method calls. This is an introduction to these features: Adding `async` on a method declaration, ensuring the return type is `Task` , `Task`, and using `await` whenever calling an `async` method. In addition, introduce async enumerables to enumerate asynchronous data sources.
- While not called out, samples will prefer the following features over alternatives:
- top level statements and implicit usings
- target-typed new
- default is preferred over default(type) or null / 0 .
- using statements over using blocks.
- using directive without { }
-auto-implemented properties, with initializers
- `?.`, `??=` and `is not null` for null safety.
- `with` expressions, discards, and deconstruction
- local functions
- Not every idiom is covered in detail. For the "everyday C#" section, the most common scenarios are covered. There will be links to more in depth coverage of those areas. Second, some idioms aren't covered in everyday C# section at all. Some of those are techniques that aren't use in the most common scenarios. Others are techniques that were more common in earlier versions of C#.
1. **Program structure and types**: As programs grow, all the techniques that organize code become important: assemblies, namespaces, types (classes, structs, interfaces, records), and generics.
- *Objective*: The developer feels more comfortable working in a larger codebase, understands OO concepts, and can express more larger scale designs in C#. Modules include:
1. *Organizing programs*: [34836](https://github.com/dotnet/docs/issues/34836) Explain the rationale to organize code as your program or library grows. Introduce the concepts to organize data and code into conceptual and physical packages.
1. *Defining types*: One article to explain why C# programs are organized around creating types that map to concepts. This will introduce the concepts of reference types and value types.
1. *Tuples and records*: These are the simplest data structures. Introduce them next. This won't cover every feature of records (namely, adding methods and behavior won't be covered).
1. *Structs*: Slightly more complicated than records, so introduce them here.
1. *Classes*: Add classes, and tie together the concepts of tuples, record, record struct and struct. Propose guidelines for deciding when to use which.
1. *Interfaces*: Explain interfaces as a mechanism to build common contracts among distinct types. This doesn't cover more advanced features such as interface members.
1. *Commonalities*: As new features have been added, the differences between classes, structs, and the record types have become fewer. That means choosing between them becomes more a matter of "making a right decision" than "making *the* right decision". Emphasize the commonality and the overlap so readers can make a reasonable decision.
1. *Generics*: The reader will have seen the basics of generics in the examples using `List` and `Dictionary`. In this unit, add more of scenarios where developers will use and create generic methods and types.
1. *namespaces*: The reader will have seen some namespaces in earlier content. Here, explain how you can organize your code using namespaces.
1. *Encapsulation, composition, Polymorphism*: Finish with an introduction to these OO concepts.
1. **Resilient code**: #[34831](https://github.com/dotnet/docs/issues/34831) This unit introduces techniques to create code that's resilient when errors occur. The syntax for throwing and catching exceptions are covered, as are techniques to avoid corrupt data or results due to how exceptions are handled.
- *Objective*: The developer can follow the general design guidelines for throwing exceptions, using finally clauses, and catching exceptions when recovery is possible.The following topics are covered:
1. throwing exceptions: How to indicate failures using exceptions.
1. catching exceptions: How to declare and use catch clauses when an exception can be handled.
1. avoiding corrupt data : Finally clauses for memory cleanup, and code structure to minimize data corruption when exceptions occur.
1. **Coding style**: This article will provide a basic set of coding guidelines. It won't be a complete set of guidelines and will focus on common techniques to write correct code. This will cover some of the most common naming conventions for types, fields, properties, and methods. It will stress guidelines for correctness (preferring braces for if / else in all cases). It will try and avoid more opinionated standards such as when to use var.
- *Objective*: The developer can write code that generally conforms to the most common guidelines. Customers can point to these guidelines as a reasonable starting point for their own standards.
1. **XML documentation**: #[#34830](https://github.com/dotnet/docs/issues/34830) The final article provides a first example of using XML comments to generate documentation. It will link to the language reference section for a more complete treatment.
- *Objective*: The developer can annotate their code with reasonable starting documentation comments .
After finishing the content in this section, a developer should be reasonably prepared for an entry level coding position.
Contributor guide
Assessment
This issue has not been assessed yet.