Showing posts with label comment. Show all posts
Showing posts with label comment. Show all posts

1 April 2014

What is shortcut for comment and uncomment in Eclipse.

Sometimes, we need comment/uncomment some lines of code.
Eclipse has tones of useful shortcuts...and some of them are about comment/uncomment :)


For single line comment (//)
To comment press CTRL + /
To uncomment press  CTRL + / again.

For multi-line  line comments ( /* */)
To comment press CTRL + SHIFT +  /
To uncomment press  CTRL + SHIFT +  \ (WARNING! it is BACKSLASH not FORWARD SLASH like in single line comment)

Just in case:
 / is  a Forwards Slash
\ is a Backslash


I wonder,what were reasons behind design decision behind to use backslash instead of forward slash for multi-line comment.

26 March 2012

Best Practices: comment


List of comment practices from various articles which i believe they are useful for my improvment :

NOTE! Not all points here are useful in all cases.They depends on application type and various other factors.
  1. (MOST IMPORTANT) Use comments when they  add  readability to code. 
  2. Unnecessary over-commenting in each line will reduce readability:
    int counter = 0; // assigning zero as initial value to the counter (Really?)
  3. Lack of commenting will increase time need to perform changes in code (as part of improvment,bug fixing,etc.) 
  4. Writing comments (e.g. JavaDoc declaration) for all public methods is a good practice as long as  they meet 1 point.(a)
  5. Document all "todo"s instantly when detected.These items may be remembered for that day but may not for tomorrow when not documented, so a buggy code will be inevitable. (a)
  6. Comment all method that solves particular bug. It will helps remember you a solution and helps understands somebody why you choose your algoritm to solve it.
  7. Comment all workaround method that's solve problems related to bugs/ limitiation in third party libraries /frameworks etc.
  8. Format your comments. 
  9. Comment  method that is buggy,BUT do NOT comment bugs details,use Bug tracker tools for that.
Sources:
a) http://java.dzone.com/articles/10-best-practices-code

[Update add 2 useful practices and "note!" paragraph

7 October 2011

How i can add comment to json

No, you can't add comment  to JSON.

First. If you need  comment in data ,that usually means that your naming convention , design are rubbish and documentation sucks, because .... Data should be self-explanatory .

Second. It is a  data-interchange format. Devices need understand this crap,not humans.

Third. You can complain on your blogs,go to psychologist to talk about it,but  no, you can't add comment  to JSON.

So... what to do?
If you really despeard to put your /*comment*/ , then you can emulate them by add   name/pair value
like :
"__comment__" : "i am addicted from add useless comment"   which should be  ignored by your application that use the JSON data,  but comment will be visible all the time and consume your bandwith and i'm afraid is nothing what you can do about it (except do NOT use comment in first place) andI don't feel sorry about your problem.

Example:
{
  "__comment__" : "justin bieder is is good as music as I in commenting my code",

"mySkills": "rubbish",  
"your" :  "json  stuff"
}

30 March 2011

How to comment in jsp

To start single/multi line comment, insert this:
<%--

 To finish comment insert this:
 --%>

Single line comment example:
<%-- i love smell of napalm in the morning --%>

multi line comment example:

<%--
- When is summer in UK?
- When rain is warm .
--%>