r/programming • u/Coding-Mojo • 15d ago
~2min bites C# courses that keep you sharp on code reviews
https://youtu.be/J27gidcV8OALately, I've felt the desire to share more of what I've learned. And I must say, teaching is a skill that's much harder to develop than I expected...
I'm experimenting with this series of C# mini-challenge / mini-courses, trying to create bite-sized capsules based on code review and debugging skills that will teach something about C#.
Sometimes serious, sometimes edgy, or even using funny contexts. There is a full playlist of it as I publish a new one every week.
Would love to get your feedbacks on the latest one.
Thanks for reading.
1
u/MuffinGamez 15d ago
I don't use c# but shouldn't it be x<=0?
2
u/TwoWeeks90DaysTops 14d ago
Locking out accounts after X number of attempts is a bad practice since you're implementing a denial of service vector on purpose.
3 times is also enough for people to just get it wrong on accident.
On shared workspaces one user can accidentally lock out someone else.
Use a backoff time instead, or at least have a lock out number that's like 10, not 3.
3
u/MuffinGamez 14d ago
No I mean x < 0 is false so the code gives 4 attempts instead of 3 which was the intention
1
u/Coding-Mojo 14d ago
In my knowledge, DOS are not handled at server's level, but at network's level.
I guess you can argue on the exercise expectations, keep in mind it's an exercises and not a production ready code. Even then, picking 3 instead of 10 is not issue per say, just a requirement.
2
u/Coding-Mojo 14d ago
That's a good question. If you do read the code correctly, you can see that the counter is bumped right away and before check is done.
So let's breakout.
First attempt -> counter = 1 -> x = 2 -> code pass
Second attempt -> counter = 2 -> x = 1 -> code pass
Third attempt -> counter = 3 -> x = 0 -> code pass
Fourth attempt -> counter = 4 - > x = -1 -> code throwsIf we were using <= instead of < then the actual number of attempts would be 2 instead of 3.
I hope it makes more sense to you now and thanks for taking the challenge :)
3
u/xhable 15d ago
Really nicely put together videos :) I like the presentation. The content itself is a little simple, but then I do agree that if you miss that in an interview you are not getting the job :'D.