While programming, you should take care to see that your code or program is readable (i.e. it will make sense to you when you read it again and it will make sense to other people who try to read it). One important step in achieving this is indenting.
The program should be indented so that different blocks start in different columns. This helps the reader of the code in identifying the various control structures, the logical blocks etc. Also write only one statement per line. For example, take the sample code given below.
public class Example {public static void main(String args[])
{int i;int b=5;double a=5.22;double d;d=(a-b)*100;
System.out.println("d="+d);i=(int)d;System.out.println("i = "+i);}}
This may seem compact but this does not help a new person to read the program. It is very easy to indent using Forte. All you have to do is type one statement per line and indenting is done automatically in Forte. You can also right-click in the Source Editor and choose 'Reformat Code' to correct any alignment problems. This is how the code will appear if there is only one statement per line and if the code is indented.
public class Example
{
public static void main(String args[])
{
}
}
This example also shows the importance of choosing sensible variable names. When reading code the variables often provide the key to what the intentions of the programmer might have been (this is particularly relevant in the case of programs which do not work.) Using sensible names for variables makes debugging possible. There is rarely time saved by using i instead of sheepcounter. Often it is time lost, and in some cases a great deal, due to the confusion that an arbitrary choice of variable names may cause.
Java® is a trademark or registered trademark of Sun Microsystems, Inc. in the United States and other countries.