• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Devaka Cooray
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Carey Brown
  • Tim Holloway
Bartenders:
  • Martijn Verburg
  • Frits Walraven
  • Himai Minh

JSP Style sheet question

 
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Paul,
I'm trying to put together a JSP and JSP style guide for my company. Could you tell me some of the reasoning for your rules for comments in the Javaranch guide?
>Try to use the // commenting style for a majority of your comments.
Why? For block comments, why is // better than /*?
>Try to use the /* */ commenting style only for temporarily commenting out blocks of code.
Why? Benefits?

 
Trailboss
Posts: 23550
IntelliJ IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Granted, if you are going to have a huge comment, the /* */ stuff is better. But! I would still use //.
The big reason is that java doesn't allow nested comments.
So let's say you have a big comment in your code and you used /* */. Then you want to temporarily comment out a big block of code. You gotta go dance around your comments ... Yuck!
JSP style: I would suggest that you try to stick to one liner code in your JSP's and move the meat of the work to helper classes. This way, you have just a pinch of Java in your JSP.
The beauty of JSP is that your graphical types can tweak the HTML-ish files and make them look good. If you have a lot of Java code in there, if they don't get confused, they might get inspired to "improve" your code.
 
Bryan Welch
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
To add a bit more about the debate between /* */ and //:
For temporarily commenting out blocks of code, avoid using
/* */. Instead, use an if block such as this:
if ( false )
{
< code to be commented out >
}
Reasoning: The big reason is that java doesn't allow nested comments. Let's say you have a many comments in your code and you used /* */. Later on, suppose you want to temporarily comment out a big block of code. With /* */, you will need to carefully work around your comments, turning on and off the /* */ blocks. With // comments, this isn't a problem. Using an if block to disable the block of code works in either situation.
Can anyone think of any problems with this logic?
 
You didn't tell me he was so big. Unlike this tiny ad:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic