Kotlin

Writing better Spring applications using SpringFu

Writing better Spring applications using SpringFu

“Truth can only be found in one place: the code,” Robert C. Martin, Clean Code: A Handbook of Agile Software Craftsmanship.

The way we structure our code has a direct impact on how understandable is it. Code that is easy to follow with no or less hidden functionality is much easier to maintain. It also makes it easier for our fellow programmers to track down bugs in the code. This helps us to avoid Venkat’s Jesus Driven Development.

The way I write Spring applications comprises heavy use of Spring annotations. The problem with this approach is that partial flow of the application is controlled by annotations. The complete flow of my code is not in one place, that is, in my code. I need to look back to the documentation to understand the annotations’ behavior. By reading just the code, it is difficult to predict the flow of control.

Luckily, Spring has a new way to code to and it has been called Spring Functional or SpringFu. In this article, I will use Kotlin to showcase some of the benefits you get from SpringFu.

Continue reading “Writing better Spring applications using SpringFu”

Share
How Kotlin’s coroutines improve code readability

How Kotlin’s coroutines improve code readability

Programs must be written for people to read, and only incidentally for machines to execute. — Abelson and Sussman

Kotlin is a new practical language designed to solve real-world problems. It is based on JVM but there are many differences between Kotlin and Java. Kotlin is a null-safe and concise language with support for functional programming. You can try programming in Kotlin here.

Kotlin coroutines provide an easy way to write highly scalable code, using the traditional style of programming, while avoiding having a thread allocated to each task.

In this article, I focus on code readability and how, in my opinion, coroutines provide a cleaner approach to writing code compared to a reactive approach. I have used Project Reactor to showcase the reactive code; however, the example can be extended to any reactive library, for example, RxJava and CompleteableFuture. Note that coroutine-based code scales as well as code written using a reactive approach. To me, coroutines are a win-win situation for developers.

Continue reading “How Kotlin’s coroutines improve code readability”

Share
Inter-Reactive Kotlin Applications

Inter-Reactive Kotlin Applications

Kotlin coroutines is one of the major features of Eclipse Vert.x 3.5.

Most of us are used to writing interactive code and going the reactive way is not a trivial paradigm shift for everyone: programming using asynchronous APIs can be more challenging than using a direct synchronous style, in particular, if you have several operations that you want to do in sequence. Also, error propagation is often more complex when using asynchronous APIs.

Continue reading “Inter-Reactive Kotlin Applications”

Share