Is it permissible to use Globals variables for debugging code?

I have a very well-thought out object-oriented structure for a large project that I am working on. However, in areas of my code, I would like to enable and disable debug sections through a set of variables located in the same access zone. My question is whether this is good practice, or if I have to implement an even more confusing pass scheme for passing debugging parameters.

+4
source share
2 answers

You should probably take a good look at the System.Diagnostics.Debug class and how it is implemented using the Conditonal attribute.

Build something like that. Ease of use is nothing against the complexity of being sure that you have all disabled it.

And, of course, C # has no glbal variables.

+3
source

You should use a debugging class that has many methods for handling debugging that are removed when building in release mode. Also, conditional methods are likely to help you.

+1
source

All Articles