Current time: 05-23-2012, 02:32 AM Hello There, Guest! (LoginRegister)


Post Reply 
 
Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Java-Coding-Rules Seminar
12-14-2010, 04:25 AM
Post: #1

Java-Coding-Rules Seminar
Many claim they can code faster if they code it in their own way. They MIGHT be able to get code out the door faster, but their program get hung up during testing when several difficult-to-find bugs crop up, and when their code needs to be enhanced it often leads to a major rewrite by them because they’re the only ones who understand their code.

Other developer may find it very difficult to get the exact flow.

So for good programming one need to follow coding rules.



Any developer should be able to understand our code with in 30secs.

Our code last longer, at any point of time it should give a clear cut of the purpose of variables & function used.

Gives a better consistency for the code and also to our team mates.

Better consistency leads to code that is easier to understand, which means it is easier to develop and to maintain. This reduces the overall cost of the Application & Maintenance.



Use full English descriptors: That accurately describe the variable,
class used.
Ex: int x1,y1;(Not user friendly)
int amount,avgInterest; (gives the exact meaning).

Use standard abbreviations:
Ex: no , num for number.

Avoid long Names: Length of the variable name should not exceed
15(<=15) characters.

Capitalize: The first letter of standard acronyms
Ex: Sql,DataBase


Constant value do not change , are typically implemented by static final of class.

One should able to distinguish constants from variables.

Use standard names all in upper case, with underscore between.

     User Friendly Not
Ex: MINIMUM_BALANCE Ex: balance
    MAX_VALUE min


Comments should be short & simple.

Types of comments:

1.Documentation: Use immediately before declarations of interfaces, classes, member functions, and fields to document them.
Syntax: /**-----------*/

2.C Style: Use to comment out the lines of code that are no longer executed. Used for commenting more than one line.
Syntax: /*------------*/

3.Single line: use to comment out single line and goes until the end of source code
Syntax: //--------




Public class HelloWorld {
public static void main(String[ ] args) {
System.out.println("Hello World!");
}
}

/** The HelloWorld class implements an application that simply prints "Hello World!" to standard output. */
public class HelloWorld {
public static void main(String[ ] args) {
System.out.println("Hello World!"); // Display the string.
}
}


@param <name> <description>
Used for member functions
Used to describe a parameter passed to a member function, including its type/class and its usage.
Declare what happens with extreme values (null etc.)
Use one tag per parameter.


 @return <description>
Used for member functions
Describes the return value, if any, of a member function. Indicate the potential use(s) of the return
value and the type/class.


@exception/@throws<name><description>
Used for member functions
Describes the exceptions that a member function throws
Use one tag per exception.

@author <name>
Used for interfaces, class
Indicates the author(s) of the code
Use one tag per author.



@version <text>
Used for classes, interfaces
Indicates the version information for a given piece of code.
When using CVS or SVN, just write $Id$.


@see/@link <ClassName>
Used for classes, interfaces, member functions.
Generates a hypertext link in the documentation to the
specified class. You can use a fully qualified class name.


Attached File(s)
.ppt  Java-Coding-Rules.ppt (Size: 215 KB / Downloads: 6)
Find all posts by this user
Quote this message in a reply
Post Reply 


[-]
Share/Bookmark (Show All)
Facebook Linkedin Technorati Twitter Digg MySpace Delicious

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  UTILIZACION-DEL-IDE-ECLIPSE-y-JAVA-2003 Seminar born_for seminars 0 430 12-14-2010 04:42 AM
Last Post: born_for seminars
  Slides-de-Aula-Java-Micro-Edition-J2ME Seminar born_for seminars 0 337 12-14-2010 04:41 AM
Last Post: born_for seminars
  Sending-and-receiving-xml-in-java-application Seminar born_for seminars 0 230 12-14-2010 04:40 AM
Last Post: born_for seminars
  Ruby-On-Java Seminar born_for seminars 0 374 12-14-2010 04:40 AM
Last Post: born_for seminars
  Oracle-AS-Java-Object-Cache Seminar born_for seminars 0 176 12-14-2010 04:39 AM
Last Post: born_for seminars
  OOPs Through JAVA Seminar born_for seminars 0 195 12-14-2010 04:37 AM
Last Post: born_for seminars
  Object-Oriented-Programming-09-Transform-UML-to-Java Seminar born_for seminars 0 415 12-14-2010 04:37 AM
Last Post: born_for seminars
  Object-Oriented-Programming-02-Java-Fundamentals Seminar born_for seminars 0 194 12-14-2010 04:36 AM
Last Post: born_for seminars
  Network-programming-and-java-Sockets Seminar born_for seminars 0 344 12-14-2010 04:35 AM
Last Post: born_for seminars
  Multi Threaded Programming Seminar born_for seminars 0 192 12-14-2010 04:34 AM
Last Post: born_for seminars

Forum Jump:


User(s) browsing this thread: 1 Guest(s)