JUnit 5: New Way of Testing in Java

This article provides an overview into the JUnit 5 features and architecture. There are many new exciting innovations which are compatible with new features in Java 8. JUnit5 is composed of several different modules from three different sub-projects – JUnit Platform, JUnit Jupiter, and JUnit Vintage. The JUnit Platform launches testing frameworks on the JVM. JUnit Jupiter is a blend of new programming model and extension model for writing tests and extensions. JUnit Vintage engine provides support for running JUnit 3 and JUnit 4 based tests on the platform. JUnit5 comes with new set of Annotations, Assumptions, and Assertions. The new architecture and features of JUnit5 make unit testing quite seamless.

Read More

Share

A Quick And Practical Example Of Hexagonal Architecture In Java

This article provides overview of Hexagonal architecture and practical example using Spring application. Hexagonal Architecture is an application design pattern which divides application into two layers – inner and outer. While, inner layer consists of core logic of application, the outer layer can have User Interface, Messaging connectors, database, etc. This isolates application’s business logic from outside concerns. Both layers communicate with each other through a mechanism of Port and Adapters. Port in this case acts as gateway for communication and adapter is an implementation of a port.

Read More

Share

Object Persistence with JPA

The most common and stable persistence mechanism has been provided by Relational databases (RDBMS) for many years. You can use ANSI-SQL (Structured Query Language) to communicate with relational database. When you are working with an object-oriented language like Java, there is mismatch with SQL syntax, as it is a procedural language. Java Persistence API (JPA) is a bridge between object-oriented language like Java and Relational database (SQL) which helps them communicate to each other.

Read More

Share

Working with Arrays in Java

Java Array is a container object that can hold a fixed number of values of the same type. You can store in Arrays either primitive types like int, short, char, byte or an object like String, Integer, etc. When you create an array, its length gets fixed. However, there are subtle differences in the way they are handled in Java as compared to other languages like C. You can have multi-dimensional arrays where each row could be of different length.

Read More

Share

Java 14 – All the New Features

The latest feature release of Java is Java 14 and it was released in March 2020. It is not a long-term support release. Java 14 will receive security updates in April and July before finally getting superseded by Java 15, which again is a non-LTS release. The current LTS release is Java 11. The new features in Java 14 like Records for concise syntax for data holding classes, helpful NullPointerExceptions with more debug information, Text Blocks for multiline string literals, pattern matching for instanceof, and switch expressions would keep you excited while working with Java.

Read More

Share

JVM Languages: Different Languages for Different Needs

Over the years, the JVM has become a software ecosystem of its own. Besides, a lot of other popular languages utilize the JVM to create valuable software. For any language, use of JVM brings a lot of benefits. JVM has become a high-performant platform which provides cross-pollination of libraries written in different languages. This post will examine some of the most popular programming languages which can run on JVM.

Read More

Share

Getting Started With Spring Boot

Spring typically requires lot of configuration and boilerplate code. As an example, for every Spring MVC application you must configure DispatcherServlet, InternalResourceViewResolver, and many other components. On the other hand, Spring Boot relies on convention-over-configuration and can quickly bootstrap a production-grade Spring application. Although, Spring Boot is mostly used to create web applications, but you can also use it for command line applications. It provides a convenient way to build microservices. You can build a Spring Boot web application into a standalone JAR which contains an embedded web server. This web server can be started with java -jar.

This post examines key features of Spring Boot and shows how to get started with it.

Read More

Share

Dependency Injection – Avoid Hard Wiring of Dependencies

Dependency Injection is a technique to supply dependencies to an object. It provides flexibility by avoiding tight coupling of dependencies. The main ways to inject dependencies is to specify object to parameterized constructor, pass the dependency through a setter method, and use of interfaces with methods to supply dependencies. You can seamlessly use Dependency Injection by leveraging third party frameworks like Spring, Google Juice, and Dagger.

Read More

Share

How to Effectively Perform Null Checks in Java

NullPointerException is a type of RuntimeException and if not handled properly it can lead to drastic situations like abnormal termination of your JRE. The most obvious way to avoid such scenario is to perform null check for each object with a risk of null value. It is tedious and creates redundant code. You can explore good practices like use of primitives, empty collections, exception handling, avoiding too many dots to handle null objects in a better way. Java Assertions, Objects, and Optional APIs provide advanced mechanism to avoid NullPointerException.

Read More

Share
Page generated in 2.252 seconds. Stats plugin by www.blog.ca