Why you should consider moving to the new Kotlin DSL in Springboot

Photo by Braden Collum on Unsplash

Version 5.0 of Spring introduced the Kotlin DSL (Domain Specific Language) for defining routes and beans.

Using the DSL, you don’t pay the uncertainty of knowing if you wired things correctly.

Did you ever spend hours debugging, just to figure out that you put the bean in a package that is not scanned? Or that you failed some annotation attribute? Or that you are missing some spring-boot-starter-something in your pom?

Forget about it. If the DSL compiles, then it is sure that spring is resolving your beans!

There exist a second big advantage in using the DSL.


There is much more in a software company behind technologies

Photo by Huang Yingone on Unsplash

Developers look at the technologies that companies adopt as one main metric when evaluating a collaboration. A decision based on this is too superficial. Do we really fear the technology? Or maybe we associate the company culture with it?

I want to tell you my story and what I would have lost if I refused to work in COBOL back in 2010 when I was 25.

Big city life

After university, I started working in a big company in Milan. I was working on a private social network, using the most recent Java technology stack. …

The definitive solution to composability

How to compose independently computed Kotlin nullables, in an easy and clean way

Kotlin + Konad = 😁 (Image by author)

In Kotlin we have null safety.

There are many advantages to using nullables in Kotlin, even if they can’t be totally considered as monad. Your API can express optionality in a clean/compile-time-safe way. Also, they bring back your side-effectful function to the pure world.

This feature is one of the most exciting and idiomatic of this language. Anyway, there is one drawback. Composability!

I will propose a solution to this annoyance.

Have you ever tried to compose nullables?

Well… I can’t say that composing independently computed values really shines. Let’s figure out a real-world use-case.

Crypto exchange

Let’s think about a crypto exchange. Suppose that when registering, they ask…

“If it compiles, it works” with Valiktor and Konad

Photo by Georgy Rudakov on Unsplash

In Domain Driven Design there is a concept of ubiquitous language. Being trivial, this is usually related to the names you give to the entities in the domain model.

However, it’s possible to take it a step further. We can turn the code into an unequivocal expression of the domain.

For example, here it follows how an American domain expert may describe a “contact” and some business rules.

A contact has a name, a surname, and an email. The name can have a middle initial. The email must be verified. You can send password recovery only to verified emails.


Builder functions, blocking, suspended, ‘Scope’… what?

Image source: Author

Kotlin coroutines are an efficient way to (re)use threads while the computation has been moved somewhere else. Coroutines are bound to the concept of Scope: to run one, you need before to declare a scope object. This is how they implement structured concurrency. To get a scope, you use the scope-builders functions, like coroutineScope{} or runBlocking{}. A scope suspends (or blocks) a thread until all of its coroutines are finished.

The following example will print “213.”

This prints 213

This means that you can’t just fire-and-forget an operation if you don’t have the plain control of your main (quite usual…

And receive the best happy birthday greeting ever from Dario

I Had an Idea

There is a colleague of mine, Dario, who gives great happy birthday greetings.

Everyone in the office is happy to receive an audio greeting from Dario. They say, “it is not a birthday until Dario sends you the greeting.”

So why not let everyone in the world be greeted by Dario on their birthday Do you want to try it out?

At the moment it is only in Italian (sorry).

Github repository here:

Ok. How?

I need an easy way for people to ask for greetings. Website? Who still uses a website in the platform era? Platform then. Which one? Facebook? Twitter…

Using the visitor pattern as a routing point (with Kotlin examples)

Photo by Aaron Burden on Unsplash

Functional programming gained a big momentum in the IT field; many things come and go, but FP is not one of them. It is much more expressive than OOP.

I started digging into it a few years ago, during the LambdaConf in Bologna, and the more insight I get, the more I love FP.

In June, I went to an applied functional programming workshop and the teacher went deep into algebraic data types and pattern matching. I also finally understood what a monad is, but this is another story.

I used to think of pattern matching as an interesting way…

Test-driven development is hard — here’s the untold truth

Image credits to https://testsigma.com/blog/ai-driven-test-automation/

These days you read a ton of articles about all the advantages of test-driven development (TDD), and hear a lot of talks at tech conferences that tell you to: “Do the tests!”, and how cool it is to do them.

And you know what? Unfortunately, they are right (not necessarily about the “cool” part, but about the useful part).

Tests are a must!

The typical advantages we list when it comes to talking about TDD are real:

  • You write better software.
  • You have protection from breaking the world when new features are introduced.
  • Your software is self-documented.
  • You avoid over-engineering.

Explaining a simple technique for barcode segmentation from images

In this piece, I’m going to explain a simple technique for barcode segmentation from images.

For the example code, I will adopt Python 2.7 in its Anaconda incarnation and OpenCV as image processing library.

I chose Python as it is a very practical choice for quickly writing examples, but the technique can be adopted in any language of your choice.

Anaconda is an interesting Python distribution that bundles a series of useful tools for scientific programming.

Segmentation is the process of identifying the position of one or more objects inside an image.

The technique that I’m going to present is…

In questo secondo articolo spiegherò come raddrizzare un’immagine che contenga elementi per i quali sia evidente una direzione comune e prevalente. Fanno parte di questa categoria le immagini contenenti testo.

Luca Piccinelli

I’m a programmer. I love programming, any language, any paradigm

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