• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

indentation help

 
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Rancher
Posts: 1776
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This might interest you Indentation and Spacing
 
Ranch Hand
Posts: 160
IntelliJ IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
That's fine.

Check out this link: Style Guide
 
Rancher
Posts: 3742
16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Bartender
Posts: 10780
71
Hibernate Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
     
    Bartender
    Posts: 2292
    3
    Eclipse IDE Spring Java
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • 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.
     
    reply
      Bookmark Topic Watch Topic
    • New Topic