5 Java Development Tips

By Kotesh Chitimalla, Sr Systems Engineer


1. Object Creation is a very expensive operation for Memory Utilization. So, only create or initialize objects which are necessary.


2. In a program, if a collection has no value and is returned, then make sure it returns with an Empty collection instead of Null elements. The unending 'if else' testing on Null elements are saved.

3. Java automatically manages the memory and memory leaks degrade the software performance. To avoid memory leakages, release the database connection after the query. Also, try using Final block and releasing instances stored in Static Tables.

4. Executing Comments: Most of the developers think comments are never executed in a program and are used for ease in understanding the code. But, they are executed. For example:

public class GFG {

public static void main(String[] args)

{

// \u000d System.out.println("PSI");

}

}

Output: PSI

Explanation:

This comment is executed because of Unicode character “\u000d” and java compiler parses this unicode character as a new line. Java allows using Unicode characters without encoding.

5. 10-50-500 Rule

In big software packages, maintaining code becomes very challenging. Developers who join fresh ongoing support projects often complain about: Monolithic Code, Spaghetti Code. There is a very simple rule to avoid that or keep the code clean and maintainable: 10-50-500.

a. 10: No package can have more than 10 classes.

b. 50: No method can have more than 50 lines of code.

c. 500: No class can have more than 500 lines of code.

d1e1871a85e906df5b85bace3dbfd254.jpg

INNOVATION FACILITY NOW OPEN

PSI's state-of-the-art Innovation Facility is now open in Valparaiso, FL. It is designed to provide a cyber secure ecosystem for development of new technologies and approaches, illustrating the company’s commitment to deliver excellence to its customers. Watch a video about the Innovation Facility.