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?
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 most recommended design principles, you should keep in mind, while writing your classes. These design principles are called SOLID, in short.
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 uses static inner classes for every new exceptional scenario. Worth reading for future software designers.
Covering some well-known and some little known practices which you must consider while handling exceptions in your next java programming assignment.
Some best practices which you need to keep in mind while designing your next multi-threaded application.
There are several reasons for migrating from old legacy systems to new advanced systems. Here are 5 of them.
13 best practices for writing highly maintainable spring XML configurations.
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.
We all know what Serializable interface does. But do we really know, what changes in your class can break your design?
Creating new objects is always an expensive process. Let’s learn how java utilize object pooling to solve this problem.
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.
Learn how to use WatchService to reload your logging configuration at runtime. Use them to reload other configurations as well.
ToStringBuilder is a utility class provided by apache commons lang library. Learn to use it to write highly customized toString() methods.
Vector doesn’t need additional synchronization while accessed from multiple threads but it degrades its performance for the same reason. Measure it’s impact.
Best way to check if string is empty or not is to use length() method and not equals(). Why? Let’s do some reasoning.
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.
Let’s see different ways to iterate over HashMap and see the differences in terms of performance they can bring.
Let’s compare performance of different for loops as well. They are everywhere in any program.
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 !!