I'm having this inconvenience while commenting. But I was wondering how you guys would do this. Lets say you have the following code:
/*Fancy function*/
function fancyFunction(){
echo "Oh yeah"
//200 more lines go here
}
And now I want to comment the whole function, you'll do this:
/*
/*Fancy function*/ <--Comment breaks here
function fancyFunction(){
echo "Oh yeah"
//200 more lines go here
}
*/
How do you do this xD
Commenting is meant to give you comments for your code. A system to tell you and other developers the reasoning behind decisions or anything else not obvious by reading the code itself.
Your best bet would be to remove the code in question. If you are using version control (and you should), you will never lose the code.
I use one-line comments "//comment".
If you get good IDE, you can comment bunch of lines by pressing one key shortcut. You can also comment comments:
commented:
I think there's no easy way around it, but here's a handy tip for fast commenting:
Now, when you'd like to comment out the function, just remove the first two slashes:
However, I strongly discourage this style. It looks ugly and version controlling should be used instead, as mentioned before several times already.
You need to use an single line comment on each line, e.g.
A lot of the editors Ive used have functionality for commenting/uncommeting the selected text in this manner. E.g. in notepad++ on the context menu select "toggle block comment".
As has been mentioned before, the long term strategy is to rely on a version control system, otherwise things can get very messy, especially when trying to comment out 200 line functions (which probably should be broken up into smaller easier to read functions).
However having said that, I have also found myself in the position of needing to comment out a function temporarily, while testing something else out, and it is an extra overhead to bounce backwards and forwards between VCS revisions, etc.
I generally only comment using the line comments (// ...), even for multiple line comments, and I exclusively use the block comments (/* ... */) for these style of temporary function replacements.