Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Line break

 
Torsten Wiederkehr
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

how to break this statement, because it exceeds the 80 characters mark:

IDataBaseAccess dataBaseAccess = (IDataBaseAccess)Registry.getInstance().lookupService(IDataBaseAccess.SERVICE_NAME);

a.)
IDataBaseAccess dataBaseAccess = (IDataBaseAccess)Registry.
getInstance().lookupService(IDataBaseAccess.SERVICE_NAME);

b.)
IDataBaseAccess dataBaseAccess = (IDataBaseAccess)Registry
.getInstance().lookupService(IDataBaseAccess.SERVICE_NAME);

Is version a.) or b.) correct, or may be both are incorrect?


ciao torsten
 
Robert Konigsberg
Ranch Hand
Posts: 172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why is this a concern?
 
Stef Widmer
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Robert,
I belive most of Java Coding Style Guides state that you should not exceed 80 characters per line (because of small screens, terminals and so on....)

I personaly feel that this is not as convenient as when you have related code in one line. I set the line wrapping in my editor to 132 characters.
What do you think? Could this be a problem for the Marking?

Cheers Stef
 
Weerawit Maneepongsawat
Ranch Hand
Posts: 203
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I think its should be


http://java.sun.com/docs/codeconv/ for ref..


fixed me..
 
Torsten Wiederkehr
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

in the official SUN coding standard is stated:

************************************************************
Line Length
Avoid lines longer than 80 characters, since they�re not handled well by many terminals and tools.

Note: Examples for use in documentation should have a shorter line length�generally no more than 70 characters.
************************************************************

That's the reason why I want to break this line, but I don't know where to break.


ciao torsten
 
mike acre
Ranch Hand
Posts: 197
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'd go with your 2nd option, but I always at least double indent when breaking over a line to distinguish between nesting.
I shouldn't get too hung up over it, you are being pedantic, your style will be fine.
 
Jon Entwistle
Ranch Hand
Posts: 118
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If possible, split lines up into several shorter lines, then break according to sun's guidelines if you still need shorter lines, i.e.



hth

Jon
[ July 07, 2004: Message edited by: Jon Entwistle ]
 
Jon Entwistle
Ranch Hand
Posts: 118
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Stef Widmer:
I set the line wrapping in my editor to 132 characters.
What do you think? Could this be a problem for the Marking?


I use a unix terminal set to the default 80 characters for all my development - longer lines cause havoc to the display (a similar problem to tabs used instead of spaces). The standard is there to try to make life easier for everyone (not just for java) and should be followed. If I were the assessor I would think that either you didn't know about the standard (bad) or were ignoring it (worse).

At the end of the day it is your call....

Regards,

Jon
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic