Is it bad to comment out code practice?

Is it bad to comment out code practice?

Commenting code is on the generally-recognized list of code smells. But unlike most of the others on the list, comments are not always bad. Generally speaking, you should strive to minimize comments and let the code speak for itself, but it is just as important to include comments when the code cannot.

Should you commit commented out code?

You should never commit commented-out code. That’s what version control is for. If you need that code back, just fetch it from the repo.

What does comment out mean in coding?

Filters. (programming) To temporarily disable a section of source code by converting it into a comment. 1.

Are comments code smell?

Comments are usually created with the best of intentions, when the author realizes that his or her code isn’t intuitive or obvious. In such cases, comments are like a deodorant masking the smell of fishy code that could be improved. The best comment is a good name for a method or class.

How do I comment in my code?

The basics tenets of commenting your code are simple:

  1. Make them brief.
  2. Keep them relevant.
  3. Use them liberally, but not to excess.

How to remove unused classes, properties, and functions?

In a larger program, if you need to remove a large amount of unused code, do it in small steps. After removing a class (or a few functions/properties/etc.), rebuild the solution, run the tests (if there are any), and run the program.

Where to find unused classes in Visual Studio?

In Visual Studio | Error List tab | Messages tab: Message IDE0051 Private member ‘xxxxxxxx’ is unused. Here’s a manual way to accomplish this that I’ve used for finding unused Classes that are marked public.

Can a dead code have a hidden reference?

Be careful however, as one of the ways code analysis for dead code can steer you wrong, is if the reference is ‘hidden’ by only ever calling the method via delegates, and of course, reflection. Internal classes that are not instantiated from any other code (CA1812).

Where to find unused code analysis ruleset in Visual Studio?

To find unused members with a Code Analysis Ruleset, from the Visual Studio menu select File -> New -> File… -> General -> Code Analysis Rule Set. Uncheck all the rules. There are many rules we don’t care about right now – and some we probably won’t ever care about.