Java Best Practices Guide

A good programmer is one who write programs (not just code). It means writing the code units which are independent enough to be re-used in multiple ways, and still they remain robust.

So let’s start identifying and learning some java best practices which can transform any code into the programs.

1. Java Design Best Practices

Following java best practices are mainly focused on system design time considerations. They are mainly useful for senior developers. Eventually, you will also be senior if not today. Why not better prepare?

8 signs of bad unit test cases

Bad unit tests are reality and everyone who does code review, face it occasionally (may be regularly). So what constitute a bad test case? How to identify bad test cases?

5 class design principles [S.O.L.I.D.] in java

5 most recommended design principles, you should keep in mind, while writing your classes. These design principles are called SOLID, in short.

Unit testing best practices

It’s overwhelmingly easy to write bad unit tests that add very little value to a project while inflating the cost of code changes astronomically. Learn how to write them correctly.

A new approach for exception handling

A new approach uses static inner classes for every new exceptional scenario. Worth reading for future software designers.

Java exception handling using inner classes

Covering some well-known and some little known practices which you must consider while handling exceptions in your next java programming assignment.

Java executor framework best practices

Some best practices which you need to keep in mind while designing your next multi-threaded application.

5 Reasons You Should Consider Migrating Your Legacy Systems

There are several reasons for migrating from old legacy systems to new advanced systems. Here are 5 of them.

2. Java Coding Best Practices

Following java best practices are focused on considerations to make while you hit the keyboard and start typing actual program. They are mainly useful for developers/programmers at all levels.

Generating secure password hash (MD5/SHA) in production

User provided password are generally very weak and easy to guess. There are many hashing algorithms in java, which can prove really effective for password security for your applications and your users.

Serializable interface guide

We all know what Serializable interface does. But do we really know, what changes in your class can break your design?

Object initialization best practices

Creating new objects is always an expensive process. Let’s learn how java utilize object pooling to solve this problem.

How to make a java class immutable

An immutable class is one whose state can not be changed once created. There are certain guidelines to create an class immutable. Let’s learn them.

Consider reloading log4j levels on runtime

Learn how to use WatchService to reload your logging configuration at runtime. Use them to reload other configurations as well.

Override toString() effectively with ToStringBuilder

ToStringBuilder is a utility class provided by apache commons lang library. Learn to use it to write highly customized toString() methods.

Use array instead of Vector.elementAt() inside any loop

Vector doesn’t need additional synchronization while accessed from multiple threads but it degrades its performance for the same reason. Measure it’s impact.

3. Java Performance Best Practices

Following java best practices can boost the performance of your java application and take it to next level. Learn them hard and keep in mind always.

Performance comparison of different ways to iterate over HashMap

Let’s see different ways to iterate over HashMap and see the differences in terms of performance they can bring.

Performance comparison of different for loops in java

Let’s compare performance of different for loops as well. They are everywhere in any program.

Best practices to improve JDBC performance

Database access is major part of any application. If you are using simple JDBC then this one is for you.

More to come …

Happy Learning !!

Comments are closed for this article!

Comments

13 Comments
Most Voted
Newest Oldest
Inline Feedbacks
View all comments

About Us

HowToDoInJava provides tutorials and how-to guides on Java and related technologies.

It also shares the best practices, algorithms & solutions and frequently asked interview questions.

Our Blogs

REST API Tutorial

Dark Mode

Dark Mode