• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Code indentation

 
Amit Kr Kumar
Ranch Hand
Posts: 100
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Ranchers
I am using the following java indentation style in all the new classes i have created
public methodA()
{
for()
{
.....
}
...
}
However in Data.java, Fieldinfo.java, Datainfo.java claasses supplied
by sun follows the following indentation style
public methodA(){
for(..){
}
...
}
Should i change this indentation style in Data.java, Fieldinfo.java, Datainfo.java so that it becomes consistent with my code ?
Amit
 
BJ Grau
Ranch Hand
Posts: 234
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Personally, I would make sure all of the code follows the same style. You can do that either by coding to the style established by the exisitng code or by changing the style of the exisitng code to fit your style.
I don't see any problem with changing the style of the existing code, as there is not much there to begin with and you are currently the only developer working on it. If this was already a large application with other developers working on it, you would want to conform with whatever style was already established.
 
Mark Spritzler
ranger
Sheriff
Posts: 17276
6
IntelliJ IDE Mac Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I always liked the way that Sun does it, it is also the way C programmers do it to.
putting the opening braces on the same line.
At first I didn't like it that way, but I got used to it, and now really find it much more cleaner and more readable
Mark
 
Jason Boutwell
Ranch Hand
Posts: 40
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I wouldn't deviate too much from this:
Java Code Conventions
 
Mark Spritzler
ranger
Sheriff
Posts: 17276
6
IntelliJ IDE Mac Spring
 
John Smith
Ranch Hand
Posts: 2937
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In my assignment, Data and DatabaseException were formatted with indent 4, but DataInfo and FieldInfo used indent 2. It looks like two different persons coded these classes. I just reformatted everything to use indent 4.
Eugene.
 
Arup Chowdhury
Greenhorn
Posts: 10
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
There are some more coding convention guides on the net. Follow the newer vesion. The one on Sun s site is pretty old.
try this. this one is relatively newer
http://www.ambysoft.com/javaCodingStandards.html
With Regards
Arup
 
Junilu Lacar
Bartender
Pie
Posts: 6548
22
Android Eclipse IDE IntelliJ IDE Java Linux Mac Scala Spring Ubuntu
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That ambysoft Java Coding Standards is 76 pages long!
I remember seeing a one-page coding standard once but for the life of me can't remember where it was or who wrote it.
The more concise the standard, the better chance that people will follow it. The most important thing is to be consistent though, IMO. My $0.02...
Junilu
 
Jason Boutwell
Ranch Hand
Posts: 40
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

There are some more coding convention guides on the net. Follow the newer vesion. The one on Sun s site is pretty old.

Whew. That's not a guide on Ambysoft, its a dissertation.
The age difference between the Sun and Ambysoft guides is a mere 9 months. I doubt that there were any major breakthroughs in coding standards in that time.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic