rbwhitaker / CSharpPlayersGuideEarlyAccess

A place to track issues with the C# Player's Guide for patches and future editions
19 stars 0 forks source link

Array Challenges #661

Open rbwhitaker opened 2 years ago

rbwhitaker commented 2 years ago

I think the challenges that deal with arrays deserve some tweaks. Here are my thoughts on what's there and what maybe needs to be there.

The Replicator of D'To. This one I've never loved, and people have often struggled with it. It isn't the most obvious. That could maybe be fixed by some revision to the description, but I'm just not in love with it, and maybe it deserves significant changes. One of the big complaints I have about this challenge is that there is an Array.Copy method that just does this. Up through 5th Edition, I've just conveniently ignored the Array class, but I don't plan to ignore it in future editions. With Array.Copy making an appearance, I think it makes this challenge obsolete.

The Laws of Freach. I like the idea of taking for-loop code and asking people to rework it into a foreach loop. I've always liked that part of this challenge. But the code samples this has you rework probably need to be changed, with the addition of the Array class, since Max and Average are (I believe) both methods (or extension methods) of arrays. I think this is conceptually sound, but I think it needs to use different examples in the future. And that probably means changing the samples in the chapter.

I also think that this is one of several areas in the book whose first real exposure in code demands dealing with user input as well. That has caused a lot of problems for readers. I think there might be room here for another challenge before these other two that just simply make an array and do something fairly direct with them, like assign specific values to them with zero user input.

660 is related.

rbwhitaker commented 1 year ago

The Replicator of D'To challenge will be updated to just use Array.Copy. I think that is a useful exercise.

I'm still leaning toward keeping the Laws of Freach but maybe still just changing the code to be something that isn't already built in.