|
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. |
||||
|
« Next Oldest | Next Newest »
|
![]() |
|||||||
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
|
User(s) browsing this thread: 1 Guest(s)
Search
Member List
Calendar
Help




![[-] [-]](images/collapse.gif)






