java

Coverage with Jacoco and Sonarqube

In most projects I have worked in, Jacoco was used as tool to determine code coverage. The configuration is fairly easy as it plugs into the JVM that runs the tests using an agent that tracks the invocations. In maven, this JVM is forked by the surefire plugin and the parameters are auto generated. The setup is well documented so in this blog post I want to shed some lights on the internals of Jacoco and Sonarqube and how both calculate their coverage metrics. I did some code digging, and I’d like to share my insights. The following information is a compilation of what I found out.

This article is inspired by this question on StackOverflow, which is basically about how Sonarqube and Jacoco calculate coverage.

Continue reading

Light Bulb Methods

While writing the article on “How to write good code”, I used the term “light bulb methods” and I want to explain bit more in detail, what I meant with this style of method structuring.

Continue reading

Optimizing Docker Images for Java

Docker is a popular technology for creating runtime environments for servers and entire systems. Docker images are easily distributed, deployed and started. But especially distribution benefits from slim images - large images take time to transmit, especially when done frequently this could have a real impact on the development speed. In this article I’ll write about some best practices for reducing or optimizing the image size.

Continue reading

Cognito based authentication for CloudFront protected resources

Cognito is a relatively new offering proving Identity Management for Apps and Services, including profile management and multi-factor authentication. CloudFront is the Content Delivery Network service provided by Amazon Web Services. CloudFront offers publicly accessible content as well as private content. Private content can be access using either signed URLs or Signed Cookies. Cognito however generates OAuth access tokens. This article describes how to build a service for creating Signed Cookies for Cloudfroint using access control provided by Cognito.

Continue reading

Integration Testing of Microservices

Integration Testing is the second-most important phase in Continuous Integration and Delivery. It’s the first time, multiple components interact with each other. The current trend towards microservice software-architectures require a new thinking regarding integration testing of distributed systems. In this article I want to reflect on the challenges for testing those architectures. In monolithic applications, components or parts are tightly bundled. Incompatibilities can often be detected already during compilation. Components interact with each other through messages that are transmitted locally, i.

Continue reading

Patterns for Dealing with Legacy Code: ServiceLoader

Legacy code is code that was not developed according to current standards of software development, is no longer maintained, and often is not or insufficiently documented. However, external, proprietary closed-source libraries often meet these criteria too. Often, this code is still operated and needs to be adapted from time to time, e.g., to comply with regulatory requirements. Legacy code often comes in the form of CLOBs. An undefined mass of lines of code, of which no one knows anymore what it does.

Continue reading

Mixins with Java

Mixins refer to additional functionality that can be added to a class. They are a special form of multiple inheritance, where properties or behaviors are inherited from several “parents.” Mixins can solve two problem areas: One wants to offer many optional features for a class. One wants to offer a specific feature for many different classes. With the help of mixins, domain models can be kept simple by defining only the essential properties and optional properties can be added via mixins.

Continue reading