JavaRanch Home    
This page:         last edited 16 February 2014         What's Changed?         Edit

Don't Write Long Lines   

If you're seeing this page, it's probably because you've put excessively long lines inside Code Tags.

For starters, it's bad practice. Forcing people to look at extremely long lines is just as bad as crowding all your code together, using excessively long (or short) names, or not indenting properly - and that applies whether you're writing actual Java code or comments.

Secondly, it messes up the window formatting here, making threads hard to read; so you're basically shooting yourself in the foot. Making code easy for others to read will get you your answers quicker.

In the olden days, coding sheets were 80 characters long, and it's still a good rule of thumb to follow; so if you find you're writing lines longer than that, break them up.

In some cases this may mean breaking up long Strings into manageable pieces and concatenating them with the '+' operator, but please remember to do it.

Also: don't use TABs for indentation. They are interpreted differently on different systems, and usually create excessive space. 2-4 spaces/indent is generally preferable.

Indeed, you should always use the 'Preview' button to check what you write before you post it.

Now, we suggest you take another look at the UseCodeTags page ... and read it carefully.


JavaRanchContact us — Copyright © 1998-2014 Paul Wheaton