Learning Kotlin: covariance and contravariance

When we work with generics, sometimes we need to help the compiler in order to accomplish what we want. By doing that, we’ll be telling the compiler if two classes are covariant or contravariant. Let’s see a couple of examples to help understand these concepts. Covariance Imagine that we want to model a factory of toys. Let’s start by creating an interface that will take a generic type: 1 2 3 interface Factory<T> { fun create(name: String): T } Now we need to define what we want to produce

Learning Kotlin: sealed classes and enums

In Kotlin we have two constructs that alow us to create a closed typed hierarchy: sealed classes and enums. Let’s take a look to them and see the differences amongst them. Sealed classes A sealed class is a class that we know all its subclasses at compile time. We can’t declare a subclass of a sealed class outside the module where it’s defined. One of the differences between a sealed class and an enum is that a subclass of a sealed class can have multiple instances, each with its own state.

Learning Kotlin: abstract classes and interfaces

When you’re studying Kotlin and take a look at abstract classes and interfaces, your first impression is that they are two very similar constructs, or at least that was my first impression. You can use both of them to share state and behavior. So, let’s see what are they and what are the difference amongst them. Abstract classes With abstract classes, using the keyword abstract you can declare members without implementation.

Learning Kotlin: configuring Kotest with Gradle

I’m about to start a new job. This will be a huge challenge for me, as I’m going to be developing in Kotlin. I’ve spent all of my professional life working with .Net, so I need to learn LOTS of things. As I believe that writing down what you learn is the best way to solidify it, I’ll be documenting all that I learn (maybe not all, but a bing chunk of it :D).

Retrospectiva 2020

No se donde va a llegar este artículo, pero empecemos rememorando lo que ha sido este 2020. El 2020 empezó como había acabado el 2019, es decir, trabajando como Technical Coach en Voxel. Esto quería decir trabajar 4 días a la semana, de 9 a 17, haciendo algo que me gusta como ayudar a un equipo a crecer, y trabajando desde casa. Respecto a mi último trabajo había perdido algo de poder adquisitivo (mismo rate pero en euros en lugar de libras y 4 días a la semana en lugar de cinco), pero había ganado mucha calidad de vida.

Lambda in .NET Core and SNS

This week I wanted to investigate how to use a Pub/Sub mechanism in an on-premise environment without needing to install anything else in our infrastructure, so using a managed service. I also wanted to make my first tests with CDK. Let me show you what I did. Goal What I want to accomplish is that a system that lives in our infrastructure communicates asynchronously with another system on it. It’s easy to simulate the sender of the message with a console application, but for the receiver I’ll need a public HTTP endpoint.

Lambda destinations

AWS recently introduced lambda destinations for asynchronous invocations. So, if you have, let’s say, a lambda function attached to an SNS event, you can configure a destination when the execution is successful and a destination when the execution fails. The destination can be either an SQS queue, an SNS topic, EventBridge or another Lambda function. As usual, the serverless framework implemented this feature quickly. Let’s take a look how to do it and what’s the difference with a DLQ.

Using MediatR as a refactoring strategy

Let me introduce you to Rachel, the new developer of the team. Rachel is an excellent developer eager to make a huge impact on the team and the organisation. When Rachel lands in the team, they treat them very well. They show her all the facilities, they teach her on how to make a good coffee with the new and shiny coffee machine and they even deploy to production in her first day.

Capturing and forwarding correlation IDs in ASP.NET Core, the easy way

The minute after I published my last article about Capturing and forwarding correlation IDs, my very good friend Hugo Biarge send me a Direct Message telling me: “Hey man! Have you read this article? This is new from ASP .NET Core 3, and it’s an easier solution than the one you explain in the article.” So, I took a look, not only at the article but also at the traces that I was already generating, and voilà, everything was already there.

Capturing and forwarding correlation IDs in ASP.NET Core

When you have different services that communicate amongst them, you need to be able to correlate those calls to perform effective analysis of any problem you might have. The way to do this is using correlation ids and pass them along in all your call to the different services you use. In this article, I´m going to explain you a way to do this in ASP.NET Core. Correlation IDs Why do you need more than one correlation ID?