Online exercises are arguably a pretty decent way to learn programming fundamentals (basic language features, syntax, develop problem-solving skills in a controlled environment, etc), but it's tightly coupled with competitive programming, which is a separate domain from real-world programming with its own standards. Code quality and maintainability have little value. using namespace std;
and #include <bits/stdc++.h>
are perfectly acceptable in CP, and are standard idioms as much as doing the opposite is in production is. That's OK. It may be aggravating that students are blissfully unaware of the issues with these practices, or with competitive coding/online judges in general, but I think the pedantry needs to be doled out judiciously. It's a matter of balancing the SO orientation towards professional, practical pedantry with the online judge domain.
- Commenting on potentially production-headed code to avoid
using namespace std;
. - Commenting that Leetcode benchmarks are unreliable, if timing is part of the question.
- Commenting that C++ code shouldn't be written with C idioms like
malloc
andfree
, regardless of the domain (a lot of beginner C++ code is basically "C with vectors" or "C withcout
"). - Commenting to request improvements to egregious formatting and variable name issues. If code is posted on SO, even if it's for CP, it should be well-formatted and readable.
- Commenting on obvious online judge/competitive programming challenges to avoid
using namespace std;
. Just let 'em--it's standard in CP and basically zero risk within that domain. The focus is on solving the problem, not clean namespacing and imports. Feel free to mention in an answer as an addendum, though. - Commenting on a Leetcode Python question that the class method should be
snake_case
, per PEP-8, or that there's no need for a class (Leetcode provides classes and methods that can't be changed, and generally don't adhere to Python standards). - Commenting that Leetcode benchmarks are unreliable, if timing isn't part of the question.
- Comments suggesting not doing programming challenges (or Leetcode) entirely.
- Commenting to nitpick when you're not really sure of the domain standard idioms and you just want to grind an axe.