File Organization Guidelines

The following is just an introductory into the file organization in Java.


1. Files longer than 2000 lines are cumbersome and should be avoided.

2. Beginning comments – 

/*
 * Class name
 *
 * Version info
 *
 * Copyright notice
 *
 * Author info
 *
 * Creation date
 *
 * Last updated By
 *
 * Last updated Date
 *
 * Description
 */

3. Package and Import statements

package com.package.sub-package;

4. Class comments as java docs.

e.g. 

/**
 *  This class is responsible for doing …..
 */

5. Class statement

e.g.

public class ClassName {}    /     public interface InterfaceName {}

6. Implementation Comment

e.g.

/*
 * This comment was not worthy of being mentioned in the java docs
 */

7. Variables in the given order – (statics, public, protected, default, private)

e.g.

public static String variable1;
protected static String variable2;
static String variable3 ;
private static String variable4;
public String variable5 ;
protected String variable6 ;
String variable7;
private String variable8; 

8. Constructors

e.g.

ClassName() {}

9. Methods

The methods must be arranged as per the functionality and not by their scope or accessibility.

10. Inner Classes

Must go at the end of the classes

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: