A Log Message is Executable Code and Comment

Although there are differences of opinion regarding how many comments one should add to one’s code, I think it’s safe to say most developers would agree that the comment in the following code snippet is superfluous: // increment the total total++; In that example, the code is simple and really is self-explanatory with a decently named variable total being incremented ...

Read More »

Microservices implementation example with Spring Boot

spring-interview-questions-answers

1. Introduction We have already been through the Microservice demo and it was so pleasing to see the wonderful response it received. Hopefully we are all good with the basics now. This tutorial will guide us all through the actual Microservices implementation, so we are well-directed every time we are asked to create it. 2. Understanding Service Registry Traditionally, when ...

Read More »

Apache Pulsar: Distributed Pub-Sub Messaging System

java-interview-questions-answers

Apache Pulsar is an open-source distributed pub-sub messaging system originally created at Yahoo and part of the Apache Software Foundation. Pulsar is a multi-tenant, high-performance solution for server-to-server messaging . Pulsar’s key features include [4] : Native support for multiple clusters in a Pulsar instance, with seamless geo-replicationof messages across clusters Very low publish and end-to-end latency Seamless scalability out to ...

Read More »

OWASP Dependency Check Maven Plugin – a Must-Have

I have to admit with a high degree of shame that I didn’t know about the OWASP dependency check maven plugin. And seems to have been around since 2013. And apparently a thousand projects on GitHub are using it already. In the past I’ve gone manually through dependencies to check them against vulnerability databases, or in many cases I was ...

Read More »

Apache Fluo: Implementation of Percolator Which Populates Google’s Search Index

java-interview-questions-answers

Apache Fluo is an open source implementation of Percolator [2] (which populates Google’s search index) for Apache Accumulo [3]. With Fluo, users can continuously join new data into large existing data sets without reprocessing all data. Unlike batch and streaming frameworks, Fluo offers much lower latency and can operate on extremely large data sets [1].       Major Features Reduced Latency ...

Read More »

Java 9: Enhancements to Optional

Previously, I wrote about the Optional class that was introduced in Java 8 to model potentially absent values and reduce the number of places where a NullPointerException could be thrown. Java 9 adds three new methods to Optional: 1. ifPresentOrElse The new ifPresentOrElse method allows you to perform one action if the Optional is present and a different action if ...

Read More »

Java 9: Enhancements to the Stream API

Java 9 adds 4 new methods to the Stream interface: 1. dropWhile The dropWhile method is similar to the skip method but uses a Predicate instead of a fixed integer value. It drops elements from the input stream while the Predicate is true. All remaining elements are then passed to the output stream. For example: IntStream.range(0, 10) .dropWhile(i -> i ...

Read More »

Java 9: JShell

JShell is a new tool introduced in Java 9 that evaluates Java statements entered on the command line. It is the first offical REPL (Read-Evaluate-Print Loop) implementation for the Java platform, and it is great for trying out Java code without having to fire up an IDE or write a full program! To run JShell, simply type jshell on the ...

Read More »

Caching method results with JCache

java-interview-questions-answers

In JCache there is a handy functionality that transparently caches the result of methods. You can annotate methods of managed beans with @CacheResult and the result of the first call will be returned again without calling the actual method a second time. import javax.cache.annotation.CacheResult; // ... public class Calculator { @CacheResult public String calculate() { // do some heavy lifting... ...

Read More »