5 ms·
You are aware of how a community driven site works? If its wrong, then go ahead and put your "right" implementation there. Beyond that, you're inferring threadi
by darkcha0s 7y ago
You are aware of how a community driven site works? If its wrong, then go ahead and put your "right" implementation there.
Beyond that, you're inferring threading into the problem. There is no mention of thread-safety in that example, nor does it claim to be. If you want to over-analyze the problem statement, that's your prerogative- that doesn't make that answer wrong however.
- donquichotte 7y ago> Beyond that, you're inferring threading into the problem. That's what I was thinking. There are no threads in the example.
- NotATroll 7y agoBut it's not at all unreasonable to think some newbie may come along, copy & paste that solution, and then call Shuffle from multiple threads. Thread safety is something that needs to be touched on constantly, and it's smart to write your code such that it would be thread safe. Because otherwise, it just looks like a normal function call. And it could take someone ages to figure out why everything is breaking if they were to actually use that example.
- stickfigure 7y agoThe newbie just needs to try to use that code in any webapp. It will break. The answer is bad and needs to be downvoted.
- ben509 7y ago> You are aware of how a community driven site works? If its wrong, then go ahead and put your "right" implementation there. It doesn't provide any indication of whether an entry has been vetted. At least with stackoverflow you can see discussion in the comments and guess whether an answer has been critiqued. If you have sufficient expertise in an area and poke around SO long enough, you'll spot the problem with an egalitarian system soon enough: the blind leading the blind.
- stickfigure 7y agoUnfortunately, the site doesn't inspire participation. There's no way for good answers to rise up above bad answers. And there are a lot of bad answers.