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

 
Mihai Radulescu
Ranch Hand
Posts: 918
IntelliJ IDE Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hallo,

I have a simple(stupid) small problem.How I break a long line like

I try teh clasic indent with 8 rule and I have like :



if I try the code formater from eclipse I have something like :



indent only with 4.

Is indent with 4 better than 8.
 
Andrew Monkhouse
author and jackaroo
Marshal Commander
Pie
Posts: 12007
215
C++ Firefox Browser IntelliJ IDE Java Mac Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Mihai,

The nice thing about standards, is that there are so many of them . Generally you pick the standard you like, or that your company specifies. In the SCJD assignment you can pick any standard you like as long as you follow it. However we generally recommend you follow the Sun Code Conventions for the Java Programming Language.

Personally I prefer 8 spaces, mainly because it makes it so much easier to see when something is an indent and when something is a carry-on line. Consider the for loop if we only use 4 spaces for a carry-on line:However with 8 spaces it is better:In my opinion the second set of code is readable, the first is not.

Regards, Andrew
 
Mihai Radulescu
Ranch Hand
Posts: 918
IntelliJ IDE Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Andrew,
So if I got it right 8 space for cary-on lines and 4 for the indent.
A cary-on is extreme long line break in small(am nice lines).
ThankX.



Regards, Mihai
 
Andrew Monkhouse
author and jackaroo
Marshal Commander
Pie
Posts: 12007
215
C++ Firefox Browser IntelliJ IDE Java Mac Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Mihai
So if I got it right 8 space for cary-on lines and 4 for the indent.
Correct.

Regards, Andrew
 
Mihai Radulescu
Ranch Hand
Posts: 918
IntelliJ IDE Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ThanX, Andrew.
'till next time!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic