Monday, January 29, 2018

7 Reasons to Use Spring to develop RESTful Web Services in Java

REST has now become a standard way to develop web services and when it comes to Java, there are many frameworks and library available e.g. JAX-RS, Restlet, Jersey, RESTEasy, Apache CFX etc, but I encourage Java developers to use Spring framework to develop RESTful web services. But, some of you might ask, why use Spring Framework to develop RESTful web services in Java? What is the advantage and why it's better than other frameworks and libraries available out there? Well, the most important reason I think to use Spring for developing RESTful web service is that you can use your Spring MVC experience to develop RESTful web services.

Sunday, January 28, 2018

How to deal with ConcurrentModificationException in Java? Beware while removing elements from ArrayList in loop

One of the common problem while removing elements from an ArrayList in Java is the ConcurrentModificationException. If you use classical for loop with the index or enhanced for loop and try to remove an element from the ArrayList using remove() method, you will get the ConcurrentModificationException but if you use Iterator's remove method or ListIterator's remove() method, then you won't get this error and be able to remove the element. It's an unwritten rule in Java that while looping through the list, you should not add() or remove() elements until the collection supports fail-safe Iterator e.g. CopyOnWriteArrayList, which operate on a copy of list rather than the original list.

Saturday, January 27, 2018

10 Unit Testing and Integration Tools and Libraries for Java Developers

In last a couple of weeks, I have written some articles about what Java developer should learn in 2018 e.g. programming languages, libraries, and frameworks, but if you have just one thing to improve or learn then that must be your automation testing skills. Testing is one of the disciplines which separates professional developers with amateur ones. It's not about following TDD, BDD, or whatever testing methodologies but at the very minimum level, you must write code to test your code automatically. Many Java developers write unit tests and integration tests which automatically run during build time, mostly by using continuous integration tools like Jenkins or TeamCity.

Monday, January 22, 2018

10 reasons to Learn Scala Programming Language

One of the questions my reader often ask me is, shall I learn Scala? Does Scala has better future than Java, or why Java developer should learn Scala and so on. Well, there can be many reasons for learning Scala e.g. you are forced to learn because it been used in the new company you joined or your solution architect decided to use it, but that's a different story. Here, we'll talk about reasons which encourage Java developers to learn Scala.  Scala has emerged as one the most powerful Java alternative in recent times. It's been the JVM language of choice, leaving Groovy and Clojure way behind, and preferred as the language people want to write most code in.

Thursday, January 18, 2018

What is a Functional interface in Java 8? @Functional Annotation and Examples

The functional interface is one of the most important concepts of Java 8 which actually powers lambda expression but many developers don't put enough effort to understand it and spend time learning lambda expression and Stream API without first understanding the role of functional interface in Java 8. Unless you know what is a functional interface and how lambda is related to it, you can't use powerful features of Java 8 e.g. lambda expression and stream API. Without knowledge of functional interface, you won't be able to understand where you can use a lambda in the code but also you will struggle to write lambda expression the method is expecting, hence, it's important to have a good understanding of functional interface in Java 8.

Wednesday, January 10, 2018

Top 20 Libraries and APIs Java Developer should know

One of the traits of a good and experienced Java developer is the extensive knowledge of API, including JDK and third-party libraries. I spent a good deal of time learning API, especially after reading Effective Java 3rd Edition, where Joshua Bloch has advised to use existing API for development rather than writing new pieces of code for common stuff. That advise making sense to me because of the testing exposure these 2nd party libraries get. In this article, I am going to share some of the most useful and essential libraries and API, a Java developer should be familiar with. Btw, I am not including frameworks e.g. Spring and Hibernate because they are pretty well known and have specific features.