Learn how to not have to implement getters, setters, and other methods for your Java applications by only using a few annotations.

Image for post
Image for post
Photo by razvanux on Unsplash

Developing in Java can sometimes feel a little bit verbose. As programmers, we are always eager to write more code but wanting to do less at the same time.

Coming from a C# background, when I started programming in Java, I’ve always asked myself: How can I avoid having to write all these setters and getters? One day I was introduced to Project Lombok.

Project Lombok is an open-source library that helps you write less code in a few areas. …


Image for post
Image for post
Photo by Micah Williams on Unsplash

Reactive forms are an alternative to creating forms in Angular. Most of the heavy lifting for creating reactive forms happens in the component class instead of the template (HTML file).

One of the big benefits of using reactive forms is that it makes testing easier. The reason for this is that all the code related to your form lives in the component class. Given this, you don’t need to access the template on your tests to test your form. Instead, you can simply write a unit test.

Module setup

The first step to implement a reactive form will be to import ReactiveFormsModule to your application’s module. …


Image for post
Image for post
Photo by Icons8 Team

Introduction

The decorator design pattern is a software design pattern that helps you add responsibilities to an object at runtime. This pattern is considered to be a structural design pattern. This type of pattern focuses on the relationships between classes and how they can help solve specific problems.

The Gang of Four, in their book Design Patterns: Elements of Reusable Object-Oriented Software, defined the intent of decorator pattern like this:

Intent: Attach additional responsibilities to an object dynamically. Decorators provide a flexible alternative to subclassing for extending functionality.

One of the key characteristics of this design pattern is that it follows the Single Responsibility Principle (SRP). This is because each “decoration” you add to an object, will be encapsulated within a class. This class’s responsibility will be to handle everything related to adding that decoration to that object. …


Image for post
Image for post
Photo by Taylor Vick

Server-side rendering and Client-side rendering

Angular applications by default rely on the browser to compile all the code. Even though this is the behavior, there is a way to change this. You can change your application to compile on a server instead of the client’s browser.

This discussion comes down to client-side rendering (CSR) vs server-side rendering (SSR). In this article, I’ll be going over what SSR and CSR are, their pros and cons, and how to convert your application to do SSR.

In simple terms, CSR relies on the client’s browser to compile the code. On the other hand, SSR relies on a server to compile the code which then gets returned already compiled to the client. …


Image for post
Image for post
Photo by James Pond

What is it? And why would you need it?

You might be familiar with CI tools such as TeamCity, Jenkins, Concourse, Travis CI to mention a few. Well, this time we’ve got a new neighbor in town.

This new neighbor offers new capabilities to automating your workflows: GitHub Actions.

GitHub Actions provides different ways to automate development tasks. Some of the things you could do are:

  • Build your applications and run tests on every code check-in
  • Deploy your application to your production servers
  • Perform different types of automated tasks when a pull request is created
  • Monitor the health of your application at a defined time interval

These are just a few ideas, but as you can see, possibilities are endless…. …


Image for post
Image for post
Photo by Wyron A

You might have heard before about the Singleton Design Pattern. It could have been in a book, online course, or in school. Back in the day when I first heard about it, I thought, why would I need to use this pattern? What I wish my professor could have told me was a real-world example of why it is needed.

Several years after that course, I had a good lesson on when to use it and why it is important. Let’s go over why this pattern is so important based on that time where everything went bad for me.

When everything started going bad…

A few years ago, I was working on a side project and it started receiving an unusual amount of traffic. Our user-facing webpage went down and no one could access it. I received a call asking what went was going on. …


Image for post
Image for post
Photo by ArtHouse Studio from Pexels

If you were to have to do the sum of integer values inside a stream of objects, you will consider a few options such as leveraging the reduce stream function. Or… the most known one: loop through all the objects and keep a variable with the running sum of values

The Stream API offers a very simple way of calculating sum, finding min or max, and calculating the average for a stream of objects.

Depending on your numeric data type (int, double or long) you might need to use IntStream, DoubleStream or LongStream. …


Image for post
Image for post
Photo by Harrison Candlin from Pexels

Sometimes conversions between data structures might become repetitive or prone to errors. If you are working with streams in Java, you might need to grab a list, convert it to a stream, and map it to another data structure.

There is a very easy way to do these types of conversions thanks to the Stream and Collectors APIs from Java. In this article, I’ll be going over different ways in which you can convert streams to other data structures.

A few of the data structure conversions I’ll be covering will be:

  • List
  • Map
  • Map grouping
  • Set
  • Partitioning
  • Grouping count elements
  • Adding…


Image for post
Image for post
Photo by Lukas from Pexels

What is an MVC handler interceptor and why should you use it?

MVC handler interceptors let you execute code before and after processing your HTTP requests. Let’s go over some scenarios where the pre and post-processing on handler interceptors could help with:
1 — Capture metrics for your HTTP requests processing times
2 — Add logs for your every one of your HTTP requests
3 — Validate routes contain the right authentication header

Setup for the interceptor class

Let’s go first over the setup required for creating your own handler interceptor. …


Image for post
Image for post
Photo by Donald Tong from Pexels

What is a Java stream?

The Stream API was introduced as of Java 8 and brought a very simple way to perform certain types of operations on your data. According to Java’s documentation, a stream is defined as

A sequence of elements supporting sequential and parallel aggregate operations

Some of the operations you’ll be able to perform with streams that we’ll cover in here are the following:

1 — Filter
2 — Map
3 — Count
4 — Reduce
5 — Verify if all elements in a stream match a criteria
6 — Verify if at least one element in a stream matches a criteria
7 — Verify none of the elements in a stream match a criteria
8 —…

About

Victor

Passionate about coding. Engineering software one keystroke at a time… ⌨️

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