Grouping and Aggregations With Java Streams

When we group elements from a list, we can subsequently aggregate the fields of the grouped elements to perform meaningful operations that help us analyze the data. Some examples are addition, averages, or max/min values. These aggregations of single fields can be easily done with Java Streams and Collectors. The documentation provides simple examples of how to do these types of calculations.

However, there are more sophisticated aggregations like weighted averages, geometric means. Additionally, there might be the need to do simultaneous aggregations of several fields. In this article, we are going to show a straightforward path to solve these kinds of problems using Java Streams. Using this framework allows us to process large amounts of data quickly and efficiently.

The Many Flavors of API Coordination

With the increasingly collaborative scenarios in which APIs are used, as well as the growing maturity and scale of microservice architectures, the idea of API coordination has become a hot topic.

Sam Newman and Phil Calçado have popularized the “Back-end for Frontend (BFF)” deployment pattern, which describes a topological approach to coordinating service API calls. However, coordinating API calls in a distributed software system is not a new problem. It has been a concern even from the early days of SOA. In my experience, software architects can often conflate the different types of coordination when trying to determine function placement in their application integration efforts. To help address this pitfall, here is a classification system I use: