Find by commenting out

No comment written on a mugWe all have to work with other people's code. A lot of the time the code that we work with is messy and hard to understand. It is nearly impossible to pinpoint the position in the code that we need to edit. This is especially true when files are thousands of lines in length.

There are a couple of ways to find the the position we are looking for. The first is to print debug or die statements to see which parts of the code is being run.

The other method is to comment out code and find out what is happening by the process of elimination. If we are commenting out code then remember this trick. We can write an end comment statement that works on its own without breaking the system.

/**/

The above code is an end comment plus a begin comment. If we add another begin comment, the end comment will still work the same, for example:

/* Commenting out this line, the above line and also this line /**/

Using the above method will allow you to comment and uncomment by just removing the initial comment line.