Multithreading in Java

Every programmer comes across Multithreading and for some reason, it has been considered hard to understand. Well, it's not. In this blog, we will go through some basics of multithreading and in the process will try to understand why it is such an important topic in software development.

A program can have multiple processes and Multithreading allows us to run these multiple processing units concurrently. Our programs by default run on a Single thread also known as the main thread. Multithreading is useful because:

Introduction to MongoDB With Java

mongoDBWe now live in a data driven world where we are generating so much data that it becomes difficult to manage this data using databases. There are different databases available for different use cases. For a long time Relational databases were used for most of the uses cases, but as the technology advanced and modern applications came which need more scalability and variety came into picture it became important to choose the right database. This is where one of the No-SQL databases comes in such as MongoDB. In this blog we will have an Introduction to MongoDB and how we can get started with MongoDB with java.

What Is MongoDB?

MongoDB is an open-source non relational, document oriented database. MongoDB being document oriented means that it stores data in JSON like documents which makes it more powerful and expressive. Data is stored in documents in Key pair values.

The Interface of Java and the Many Faces of It

Before beginning the post of Interface of many faces, have you ever heard a phrase, “Man Of Many Faces”? if not, it means a person can be of everything or anything when it comes to portraying something. It can be one thing and a minute after another without losing its strength.

Java’s interface fits perfectly for this title. It is an integral part of java and has become so powerful over the years, that it shifted the way a Java programmer thinks. It has added various ways of doing things in Java. Depending on the number of methods only, an interface’s definition as well as the object creating process changes.

Java 8 Optional Usage and Best Practices

According to the Oracle documentation, an Optional is a container object that may or may not contain a non-null value. It was introduced in Java 8 to cure the curse of NullPointerExceptions. In essence, Optional is a wrapper class that contains a reference to some other object. In this context, an object is just a pointer to a memory location and it can as well point to nothing. Another way to look at it is as a way to provide a type-level solution for representing optional values instead of null references.

Life Before Optional

Before Java 8, programmers would return null instead of Optional. There were a few shortcomings with this approach. One was that there wasn’t a clear way to express that null might be a special value. By contrast, returning an Optional is a clear statement in the API that there might not be a value in there. If we wanted to make sure that we won't get a null pointer exception, then we would need to do explicit null check for each reference, as shown below, and we all agree that’s a lot of boilerplate.

Cassitory: Redundancy Tables Within Cassandra

After working with Cassandra for a while and not having Apache Spark as a viable option, running different queries may become quite a challenge.

In the eventual case where you want to execute a query that would not be possible with the current table structure, Cassandra recommends having redundancy tables because storage is cheaper than memory.