markjprice / cs10dotnet6

Repository for the Packt Publishing book titled "C# 10 and .NET 6 - Modern Cross-Platform Development" by Mark J. Price
859 stars 373 forks source link

Chapter04 composite #107

Open DickBaker opened 2 years ago

DickBaker commented 2 years ago
  1. the vs4win\Chapter04.sln omits 5 projects
    • CallStackExceptionHandling
    • CallStackExceptionHandlingLib
    • PrimeFactorsApp
    • PrimeFactorsLib
    • PrimeFactorsTests
  2. in PrimeFactors project Primes.cs the analysers suggest adding readonly and simplification, e.g.
    • public static readonly int[] PrimeNumbers = new[]
    • number /= divisor;
  3. in WritingFunctions Program.cs several statements are commented-out, whereas devs will want to experience these
  4. in WritingFunctions Program.cs the CalculateTax & FibImperative can be much simplified by using modern switch syntax
  5. the .gitignore file is negligible, so any edits for PR include *.obj etc
  6. no .editorconfig (with root=true) to ensure any PRs conform to author's style for consistency
  7. various trailing blanks, inconsistent mix of file/block namespace, unconsolidated Microsoft.NET.Test.Sdk versions, namespace non-match folder hierarchy, some/not top-level [yes I get dotnet7.md advice, but suggest .NET-6 consistency]
  8. GH repo lacks Chapter13-Chapter19 artefacts [yes I get that 18-20 are Bonus Content]

I am submitting a PR with my contrib to the above (use diff to clarify). BTW Chapter04 caught my eye with MJP's recent commit but other Chapters probably similarly afflicted.

markjprice commented 2 years ago

Hi Dick,

1a. The PrimeFactors.sln file references the three exercise files: https://github.com/markjprice/cs10dotnet6/blob/main/vs4win/Chapter04/PrimeFactors.sln

1b. I will update the Chapter04.sln to add the other two projects. Thank you.

  1. readonly keyword is introduced in Chapter 5. The reader is introduced to language features like this slowly to build up their knowledge. Early chapters deliberately use simpler concepts to avoid overwhelming them.

  2. Developers can uncomment out those statements when they are ready to see what they do. But until then they should stay commented to match the "working through the book" experience.

  3. An implementation of FibImperative that uses switch expressions is shown in FibFunctional. The point of step-by-step tasks in an educational book is to build up from traditional style of coding to more modern style of coding so the reader can see the diffences and benefits.

  4. and 6. and 7. This repository is used to share the code samples for the book. Almost all readers just download the ZIP and do not use Git. Unlike most repos on GitHub that are for real projects and only include the current best practice code and configuration, this one is not a repo that readers usually PR, although they are free to do so. I make choices that work best for a learning experience, not what would be used in a real world project.

  5. Chapters 13 to 19 are in the PracticalApps folder: https://github.com/markjprice/cs10dotnet6/tree/main/vs4win/PracticalApps