Why Parallel Streams May Not Be Always Faster

The Stream API was introduced in Java 8 as an efficient way to operate on collections. Parallel streams were introduced as a part of it for parallel processing and to make the application run faster.
Though parallel streams are supposed to increase your application performance by splitting the task between multiple threads and completing them faster than sequential execution, there are chances parallel streams can sometimes slow down the entire application.

Threads In Sequential And Parallel Execution

Consider an example where a stream is run on a list of numbers, which transforms the number by multiplying it by 10 and returns the result. …


Effective Practices for Code Review and Code Quality

The widely accepted norm for reviewing code is to raise a Pull Request, open for comments from the entire team. However, this does not bode well when people prioritize their own work over reviewing. Either the Pull Request awaits reviews for a long time, or is even merged without a proper review. The unending delay to review causes the developers, the overhead of context switching between features while the merge conflicts start to pile up.

There are also teams where the responsibility of reviewing the majority of the Pull Requests ends up on just one person. Only that developer who…


Resolving The N+1 Query Problem: Example In Spring Boot

The N+1 query problem is said to occur when an ORM, like hibernate, executes 1 query to retrieve the parent entity and N queries to retrieve the child entities. As the number of entities in the database increases, the queries being executed separately can easily affect the performance of the application. This article will demonstrate how N+1 queries occur and their solution through an example in spring boot.

The N+1 Query Problem

Consider a Content Management System that stores a list of articles per publication. A publication can have a category and list of articles associated with it. …


Side Effects of Having Mutables in a Set in Java and Why Python Restricts This

Set is a built-in data type present in both Python and Java but both of these languages handles the elements in a set differently.
Though the underlying implementation of set is the same in both languages, Java lets you add mutable objects, such as a list to a set, whereas Python does not.

Python Restricts Adding A List To A Set

In python, when you try to add an entire list to a set, compiler throws an error:


Better practice for naming methods that returns boolean

The usual convention to name methods that return boolean is to prefix verbs such as ‘is’ or ‘has’ to the predicate as a question, or use the predicate as an assertion. For example, to check if a user is active, you would say user.isActive() or to check if the user exists, you would say user.exists().

But when the intention is to check if the user is not active, I've come across code that is written as user.isNotActive() or user.isInactive(). …


Behind the Scenes of Streams and Optionals

If you have ever used Streams and Optionals in Java, you must have come across lambda expressions and functional interfaces. But how exactly are lambda expressions tied to functional interfaces?

This article will talk about functional programming in Java and how Streams and Optionals make use of functional interfaces.

What is a functional interface?

An interface that has only one abstract method (unimplemented method) can qualify to be a functional interface. It may or may not have other default and static methods.


How does your room look when you have all your things cluttered on your table/shelf? How long will it take to find things from the heap of dump?

Thats exactly how a codebase written with more than 25 lines of code in a function and methods not at the right place will look like.
The code might run without errors and you might very well understand the code you wrote.
But the quality of code you write should be determined by how well another developer can understand your code.

When it comes to object oriented programming, maintaining a clean codebase…


Often we like to attach abilities to our class but it is mostly done as a delegate and not as a mixin in Java.
We will explore in this blog on implementing mixins in Java using first class collections.

First class collection means a collective object is given domain importance. It has to behave as a collection as well as a domain object.

Rule 4: Object Calisthenics by William Durand

Any class that contains a collection should contain no other member variables. If you have a set of elements and want to manipulate them, create a class that is dedicated…

Thameena S

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store