• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

indentation help

 
Mohan Mehra
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
String password = "root123";
args1[5] = oidName;
Connection conn = null;

look at the above lines and tell me is it the correct way of indentation. i.e., including space before and after "=" sign.
 
John Jai
Rancher
Posts: 1776
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This might interest you Indentation and Spacing
 
Riaan Nel
Ranch Hand
Posts: 160
IntelliJ IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That's fine.

Check out this link: Style Guide
 
Joanne Neal
Rancher
Posts: 3742
16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Mohan Mehra wrote:is it the correct way of indentation* spacing

It is a commonly used way of spacing. The 'correct' way is whatever the style guide you are using says. If you don't have a style guide, then the 'correct' way is whatever style you prefer.

*Indentation is how far the first non-white space character is from the left edge.
 
Winston Gutkowski
Bartender
Pie
Posts: 10508
64
Eclipse IDE Hibernate Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Mohan Mehra wrote:look at the above lines and tell me is it the correct way of indentation. i.e., including space before and after "=" sign.

What you have looks fine to me.

Other than a few very general rules, such as:
1. Spacing improves readability.
2. Uses spaces for indentation, NOT tabs.
3. Follow basic naming conventions - class names start with a capital letter; most other things (fields, methods and parameters) start with a lowercase letter.
4. Be consistent.
you are probably the best person to decide what is clearest for you.

As for the links you've been given, remember that they are guidelines, NOT rules (even though they're written like rules).
Specifically, there are "rules" in those pages that I don't follow:
  • I always use ALL_CAPS for public constants.
  • I ignore most of section 3, because I simply don't agree with it (especially 3.1, which is utter nonsense).
  • I follow Sun's convention (see below) for matching braces ({}).
  • but that doesn't mean you have to.

    I will say again though - whatever you do decide, be consistent about it.

    The guidelines from Sun itself can be found here.

    Winston
     
    Roberto Perillo
    Bartender
    Posts: 2271
    3
    Eclipse IDE Java Spring
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Winston Gutkowski wrote:The guidelines from Sun itself can be found here.


    This is exactly the code conventions that I use, with the exception that it suggests 80 columns, and I normally use at least 160.
     
    • Post Reply
    • Bookmark Topic Watch Topic
    • New Topic