Reputation: 349
How do you guys write comments on some simple code that you use just for yourself?
I mostly write JavaScript and PHP code, and I can't really feel like I found a nice way to write comments.
If I have a short line of code, I usually do this:
x = doThis(getSomeValueFromSomewhere()); // This is a short line of code
Which seems really nice I think, but it doesnt really works when the line gets a little longer or on multiple lines,
// Dont really like this since it's not clear if it describes only line 1, or all lines.
aLongerVariableName = (getSomeValueFromSomewhere() == "this is what I want") ? "true value" : "false value";
x = doThis(aLongerVariableName);
So, how do you do it?
Upvotes: 0
Views: 204
Reputation: 504
One simple way to improve the comment / decomment blocks in javascript, that works very easy and fast while programming.
When you want to make a comment block in javascript you need to add this well known way:
/*
...
*/
So when you need to decomment you need to change the beginning /* and the end */, but I used like this:
/*
...
//*/
That way changing the beginning /* to //* you will decomment the whole block, only addning one character and without the need to search for the end of the comment.
Upvotes: 2
Reputation: 9096
(*
* For blocks of comments that serve as important documentation
* e.g descriptions of functions.
*)
maybe reformatted as
(* For blocks of comments thet serve as important documentation
* e.g descriptions of functions. *)
And the // for short inline comments like you do. Don't forget that Ctrl-/ is your friend ;-)
Upvotes: 0