Quantcast
Channel: Best Practices - HowToDoInJava
Browsing all 26 articles
Browse latest View live

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

Classes are the building blocks of your java application. If these blocks are not strong, your building (i.e. application) is going to face the tough time in future. This essentially means that not so...

View Article



8 signs of bad unit test cases

If you have been in software development for a long time, then you can easily relate with the importance of unit testing. Experts say that most of bugs can be captured in unit testing phase itself,...

View Article

How to generate secure password hash : MD5, SHA, PBKDF2, BCrypt examples

A password hash is an encrypted sequence of characters obtained after applying certain algorithms and manipulations on user provided password, which are generally very weak and easy to guess. There are...

View Article

Hibernate 4 example to get entity reference for lazy loading

By Wikipedia definition, Lazy loading is a design pattern commonly used in computer programming to defer initialization of an object until the point at which it is needed. We know that in hibernate...

View Article

How to correctly set result path in struts 2

Here, result path means the location of JSP files or other view files which Struts 2 will resolve after executing the code in Action classes. These result paths are mentioned in “location” of @Result...

View Article


Checked vs Unchecked exceptions in java

In many of the projects we have worked on, we have seen different ways of coding and various different strategies, code formatting, class naming styles, databases and technologies and blaw blaw. The...

View Article

Best practices to improve JDBC performance

Java database connectivity (JDBC) is the JavaSoft specification of a standard application programming interface (API) that allows Java programs to access database management systems. The JDBC API...

View Article

Do not specify version numbers in Spring schema references

If you have worked on Spring projects, then you must have seen spring configuration files where in header you specify the schema references for various spring modules. In schema references, we mention...

View Article


13 best practices for writing spring configuration files

Spring is a powerful Java application framework, used in a wide range of configuration options. Its best feature if that it provides enterprise services to Plain Old Java Objects (POJOs) called beans....

View Article


Create eclipse templates for faster java coding

Most of us who have worked on eclipse IDE for writing code, must have use shortcuts like main or sysout and then hit CTRL+SPACE, it converts the shortcut into public static void main(String[] args){…}...

View Article

Java clone – deep and shallow copy – copy constructors

A clone is an exact copy of the original. The java clone() method provides this functionality. Learn to create shallow copy, deep copy and using copy constructors in Java. The post Java clone – deep...

View Article

Java Serialization – Dos and don’ts for correct serialization

Java Serialization - Dos and don'ts for correct serialization and deserialization. Learn to use serialVersionUID, readObject and writeObject with example. The post Java Serialization – Dos and don’ts...

View Article

Performance Comparison – Different For Loops in Java

For loop is very common control flow statement in programming languages such as java. I am not going to describe the basics of “for loop” as it is beyond the scope of this article and most of us are...

View Article


Always Use length() Instead of equals() to Check Empty String

In your day-to-day programming activities, you must be coming across multiple situation where you need to check if a string is empty. There are various ways to do this and some use string1.equals(“”)....

View Article

Use Array instead of Vector.elementAt() for Better Performance

Vector is a another legacy implementation of List interface provided with java bundle. It is almost similar to ArrayList expect it is synchronized also. It has its own advantages as well as...

View Article


Top 20 Java Exception Handling Best Practices

Learn the top Java exception handling best practices to follow in any Java application. These best practices are application for kind of java applications. The post Top 20 Java Exception Handling Best...

View Article

Java NullPointerException – How to effectively handle null pointer in Java

Java NullPointerException is an unchecked exception and extends RuntimeException. NullPointerException doesn’t force us to use catch block to handle it. This exception is very much like a nightmare for...

View Article


RESTEasy – Share Context Data with ResteasyProviderFactory

Many times we get into situation where we have to pass data from-to multiple layers in our application. An example can be application using interceptors. Suppose we have two interceptors in our...

View Article

Java ConcurrentHashMap Best Practices

The ConcurrentHashMap is very similar to the HashMap class, except that ConcurrentHashMap offers internally maintained concurrency. It means you do not need to have synchronized blocks when accessing...

View Article

Java Override toString() with ToStringBuilder

ToStringBuilder is a utility class provided by apache commons lang library. ToStringBuilder is a utility class provided by apache commons lang library. It provides a consistent and better control over...

View Article
Browsing all 26 articles
Browse latest View live




Latest Images