Skip to content
This repository has been archived by the owner on Aug 31, 2021. It is now read-only.

[C#] constants new exercise #1877

Merged
merged 50 commits into from
Aug 6, 2020
Merged

[C#] constants new exercise #1877

merged 50 commits into from
Aug 6, 2020

Conversation

mikedamay
Copy link
Contributor

@mikedamay mikedamay commented Jul 10, 2020

Please review Constants.cs - starting point, Example.cs - result of refactoring, introduction.md and instructions.md.

All other files except csharp/config and hints.md are complete apart from proofing and show the direction of travel.

mikedamay and others added 30 commits June 9, 2020 13:22
Copy link
Member

@ErikSchierboom ErikSchierboom left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like the idea of the refactoring exercise. My only concern would be that for a student it would be a relatively boring exercise I feel. I was thinking if perhaps we could introduce another concept in this exercise, possibly the fact that there are read-only collection types?

@@ -0,0 +1,18 @@
The `const` modifier can be (and generally should be) applied to any field where its value is known at compile time and will not change during the lifetime of the program.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like how briefly you've described it. The const modifier can also be applied to variables, but I assume you'll add that to the after.md file (which makes sense).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done


## 5. Ensure that the developers cannot be tampered with

At present the dictionary containing the hard coded privileged developer identities is returned by a call to `GetDevelopers()`. This is not ideal as the caller can modify the dictionary. Find a way to prevent the caller modifying the details of admin on the `Authenticator` object.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will students know about ReadOnlyDictionary? If not, this might be something that we could introduce in this exercise too to make the exercise a bit more interesting.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done


## 3. Remove set accessor or make it private for any appropriate field

Remove the `set` accessor or make it `private` for any appropriate property on the `Authenticator` class or `Identity` struct.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the example, I don't see this being applied to any properties. Am I mis-reading the code?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right. The students would not have responded well to a "trick" question. Changed GetAdmin() to a property and changed task 3 to require immutability. It wouldn't be a bad place to introduce the concept except that we already have 3 concepts.

@@ -0,0 +1,21 @@
The authentication system that you last saw in (TODO cross-ref-tba) is in need of some attention. You have been tasked with cleaning up the code.

## 1. Set appropriate fields and properties to const
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a bit of a technical description, but I must admit that I could not come up with a nice name either. Maybe something like "Ensure that constant values cannot be tampered with"

Copy link
Contributor Author

@mikedamay mikedamay Aug 1, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that making variables readonly is consistent with your wording which itself mentions constants. I think the test here is to find all the appropriate candidates. I am taking the view that the syntax is trivial.

@@ -0,0 +1,21 @@
The authentication system that you last saw in (TODO cross-ref-tba) is in need of some attention. You have been tasked with cleaning up the code.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe you could mention that you'll not only be cleaning up the code, you'll also be hardening it to improve safety or something like that.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Comment on lines 32 to 35
// However, I'm not sure this should be a test.
// I can't leave the above explanation in as a) it gives too much away, b) the in-browser
// student won't see it, so the student won't really understand what the problem is in the event
// of the test failing.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hah yes, this is a tricky one! I think an analyzer could be really useful here, as I also fail to see a way in which you can have this test and not give away the solution.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Raised issue exercism/csharp-analyzer#56 and removed test.

@mikedamay
Copy link
Contributor Author

closed to finalize - will reopen shortly

@mikedamay mikedamay closed this Jul 31, 2020
@mikedamay mikedamay reopened this Aug 2, 2020
@mikedamay mikedamay marked this pull request as ready for review August 2, 2020 06:50
@mikedamay mikedamay requested a review from a team as a code owner August 2, 2020 06:50
@mikedamay
Copy link
Contributor Author

All files complete and proofed except csharp/config.json which will be updated before merging.

@mikedamay mikedamay merged commit 20036f0 into exercism:master Aug 6, 2020
@mikedamay mikedamay deleted the csharp/constants branch August 6, 2020 13:30
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants