Thursday, July 4, 2019

Java8: What it meant?

According to a recent survey done by Jetbrains, a whopping 83% developers are using Java8 regularly. This shows the impact Java 8 had and is still carrying on to have in Java developers' world. This is particularly due to the way Java8 brought-in a lot of new ways to improve developers experience and eventually cutting-off a lot of criticism like code verbosity, lack of functional programming etc.

Although it can't be said that Java8 has become a functional programming language. However, it brings in those nice things from functional world, and is still not moving away completely the "Java" way of doing things. This has been the trademark of Java - language developers have always been considerate and kind. Enough attention has been given to ensure that the new features are backward compatible. And, the more we go into details, we find that some of them have been very clever and neat indeed.

This is perhaps one reason Java has been so popular. A new release almost never means, you need to throw everything you have been doing and start new.

Some of the important Java 8 features:
  • Lamda Expressions
  • Method Reference
  • Default Methods in Interface
  • Streams
  • Functional Interface (Consumer, Supplier, Function, Predicate )
  • Optional
  • New changes in Reflection API - parameter types and repeatable annotations
  • Date and Time API
If you want to know more you can take a look at Oracle's official website here: Whats new in Java8?

Will try to explore each of these features and more in upcoming blog posts.

Till then, happy coding! :)

Monday, July 1, 2019

What is loose coupling?


When two layers or components or classes (in context of OOP paradigm) interact with each other or uses some other component, they are coupled in certain ways. Also, known as "dependencies".  


The lesser a component know about its dependencies the looser coupled they are.

The information they need to know in order to use them, such as creating a new instance.
One of the biggest advantage is maintenance. The looser coupled code is, a lot easier to maintain.

Some of the ways we can promote loose coupling in Java:

  1. Passing Interfaces instead of concrete classes.
  2. Look for the use of new keyword for creating a new object, and using factory method or Dependency injection.
  3. Creating Rest/Messaging/Event interfaces to interact instead of using direct (like maven) dependencies of Jar files. 



Prototype

Prototype is another creation pattern. Intent:  - Intent is to create objects by cloning existing instance  - Specify the kinds of obj...