Aug 8, 2013

Core Java Best Practices -- Part 1

"Best Practices" is one of the key areas, and often you can impress your interviewers, peers, and code reviewers by applying the best practices to your code. Here is a sample class that can be used as a key to store data in Maps or in Hibernate queries to as where clause parameters. The best practices applied are

Make your objects immutable where possible as immutable classes are inherently thread safe.

Don't reinvent the wheel, and use proven third-party libraries.

Use the Comparable interface if you want to sort your objects naturally.