Results 1 to 7 of 7
Thread: Java coding Best Practices
- 05-23-2009, 07:59 PM #1
Member
- Join Date
- Dec 2008
- Posts
- 30
- Rep Power
- 0
- 05-24-2009, 04:50 AM #2
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
My recommendation is Suns' coding conventions in Java programming.
Code Conventions for the Java(TM) Programming Language: Contents
- 05-26-2009, 03:56 AM #3
Along with that, I would suggest doing things in a consistent manner. Choose an approach for routine things, and always do it the same way. Basically, avoid taking coding short cuts. Consistency allows others to get a feel for your style, and it also helps you to avoid making trivial mistakes that are sometimes hard to find.
- 05-26-2009, 09:11 AM #4
Member
- Join Date
- Apr 2009
- Location
- Pretoria, Gauteng, South Africa
- Posts
- 43
- Rep Power
- 0
Stevie, could you please give an example of what you mean about consistency? I do not really follow.
Tshegofatso Manakana
a.k.a Untouchable ™
- 05-26-2009, 09:30 AM #5
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
I think he's talking about a common ways all others following. Same design pattern may be, which most people do.
- 05-26-2009, 03:19 PM #6
Here is a good example. You can write an "if" statement two ways:
if (condition) method();
if (condition) {
method();
}
Both are correct, but the first way only works if you only want to execute one statement after the "if". The second way always works. I *always* put braces after an "if", even when it is not necessary.
This sounds trivial, but my point is that there are many little things like this. If you do these many little things each in a consistent manner, then your coding style will appear consistent to others. Not to mention, when you come back to something you wrote after two years, you will be able to figure out what you did ;-)
Another good habit is to write brief, meaningful comments *while* you code. A good comment should be a short as possible, but no shorter. Explain *why* you are doing something; the code should be clear enough to to say *what* you are doing.
If you are a professional programmer, then other people will work on the code you write. Remember to treat them the way you want to be treated.
- 05-27-2009, 04:30 AM #7
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
Similar Threads
-
Coding an FTP server in java
By Zucheto in forum NetworkingReplies: 3Last Post: 06-22-2008, 04:24 AM -
Java Coding Competition
By nbrain in forum Java SoftwareReplies: 0Last Post: 05-22-2008, 05:38 PM -
Coding Java on a Mac
By Menre in forum New To JavaReplies: 5Last Post: 05-06-2008, 05:49 AM -
best practices guide to Java/J2EE web aps
By javaforme44a in forum New To JavaReplies: 7Last Post: 07-18-2007, 07:47 AM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks