• 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

Code indentation

 
Ranch Hand
Posts: 100
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I wouldn't deviate too much from this:
Java Code Conventions
 
Mark Spritzler
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Good Link Jason
Mark
 
Ranch Hand
Posts: 2937
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Sheriff
Posts: 17644
300
Mac Android IntelliJ IDE Eclipse IDE Spring Debian Java Ubuntu Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
She's out of the country right now, toppling an unauthorized dictatorship. Please leave a message with this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic