• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

Code indentation

 
Ranch Hand
Posts: 100
  • 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
 
Ranch Hand
Posts: 234
  • 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.
 
ranger
Posts: 17346
11
Mac IntelliJ IDE Spring
  • 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
 
Ranch Hand
Posts: 40
  • 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
Posts: 17346
11
Mac IntelliJ IDE Spring
 
Ranch Hand
Posts: 2937
  • 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.
 
Greenhorn
Posts: 10
  • 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
 
Marshal
Posts: 15875
265
Mac Android IntelliJ IDE Eclipse IDE Spring Debian Java Ubuntu Linux
  • 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
  • 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.
 
When you have exhausted all possibilities, remember this: you haven't - Edison. Tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic