Understanding JavaScript Promise

The JavaScript Promise is a concept that every modern self-respecting web developer should be familiar with. No matter if you just started learning JavaScript or trying to catch up on the JavaScript language updates. If you want to understand the JavaScript Promise, this article is for you.

I will quickly take you through the theory of Promises and jump right into its API with practical usage examples. After reading, you will be ready to work with Promises created by JavaScript frameworks but also know how to create your own.

Enough of the introduction. Let’s get this show on the road.
Continue reading “Understanding JavaScript Promise”

What is Spring bean?

In short, a Spring bean is an object which Spring framework manages at runtime. A Spring bean is a basic building block of any Spring application. Most of the application logic code you write will be placed in Spring beans.

The management of a Spring bean includes:

  • creating an object
  • providing dependencies (e.g. other beans, configuration properties)
  • intercepting object method calls to provide additional framework features
  • destroying an object

A Spring bean is a fundamental concept of the framework. As a user of Spring, you should have a deep understanding of this core abstraction.

Keep reading and you’ll find out all you need to know about Spring beans.
Continue reading “What is Spring bean?”

Injecting Spring Prototype bean into Singleton bean

Have you ever wonder why singleton is the default scope for Spring beans? Why isn’t it prototype?

It’s not a random choice. It’s because the vast majority of business logic we create can be safely kept in stateless objects. And the best choice for stateless beans is the singleton scope. The prototype scope is better for stateful beans to avoid multithreading issues.

Yet, sometimes you need to mix both and use a prototype bean in a singleton bean. This particular case is a bit tricky. In this article, I’m going to explain to you different ways of accessing prototypes in singletons.

So let’s begin.

Continue reading “Injecting Spring Prototype bean into Singleton bean”

How to bind @RequestParam to object in Spring

Do you have multiple parameters annotated with @RequestParam in a request mapping method and feel it isn’t readable?

The annotation looks pretty straightforward when there’s one or two input parameters expected in a request but when the list gets longer you might feel overwhelmed.

You cannot use the @RequestParam annotation inside objects but it doesn’t mean you’re left with no other solution. In this post, I’m going to show you how to bind multiple request parameters to an object in Spring application.

Continue reading “How to bind @RequestParam to object in Spring”

The JavaScript runtime environment

Have you just started learning JavaScript?

Or maybe you already have some language experience but want to understand JavaScript runtime in more details?

Whatever reason brought you here, there are a few elements of JavaScript runtime that you should get to know.

In this article, I’m going to show you how the JavaScript runtime environment works under the hood. You’ll learn about its elements, their responsibilities, and the way they interact with each other.

Are you ready?

If so, let’s start with the first element of the puzzle.

Continue reading “The JavaScript runtime environment”

Spring Boot application.properties file

Spring Boot comes with a built-in mechanism for application configuration using a file called application.properties. In this article, I’ll show you how to effectively use the application.properties file in custom scenarios.

I’m not going to discuss properties specified by the Spring Boot framework. Working with existing configuration keys is pretty straightforward. You can easily find common keys in the official documentation.

This post covers defining custom properties, handling data types, and working with properties on different runtime environments. If that’s what you’re looking for, keep on reading.

Continue reading “Spring Boot application.properties file”

Spring Custom Validator by example

Since you’re here, you probably reach the point in which standard annotations like @NotNull or @Size don’t meet your expectations. Fortunately, I have good news for you. Creating a custom validation annotation is pretty easy. In this post, you will learn how to create a custom constraint annotation and a corresponding validator class. You will also see how to use Spring beans inside a custom validator.

Let’s just right into it.

Continue reading “Spring Custom Validator by example”

Java class naming conventions, rules, and best practice

Every programmer agrees naming classes is highly important for code readability. Proper naming decrease the time needed to understand the code base. Many developers will also agree that class naming isn’t easy. There are numerous queries around the best practices which come not only from the beginners.

The aim of this article is to put in one place answers for the most popular questions around Java class name conventions and community standards. I’ll cover technical Java language restrictions, common conventions, and popular class naming best practices.

So much by way of introduction. Let’s get down into it.

Continue reading “Java class naming conventions, rules, and best practice”