algorithm kotlin

Feedback on the Josephus problem

My last week article was about the solving the Josephus problem in Kotlin. For ease of comparison, here’s the version I wrote originally: class Soldier(val position: Int) { var state = State.Living lateinit var next: Soldier fun suicide() { state = State.Dead } fun isDead() = state == State.Dead } enum class State { Living, Dead } class Circle(private val size: Int, private val step: Int) { private val first = Soldier(0) init { var p

algorithm kotlin

Solving the Josephus problem in Kotlin

I recently stumbled upon a post telling about the Josephus problem and trying to solve it in different scripting languages. For the sake of brevity, here’s the problem (taken from the referenced post): Flavius Josephus was a roman historian of Jewish origin. During the Jewish-Roman wars of the first century AD, he was in a cave with fellow soldiers, 40 men in all, surrounded by enemy Roman troops. They decided to commit suicide by standing in a ring and counting off each third man. Each

interview recruiting

The sad state of developer interviews

Recruiting is a complex process, and recruiting developers even more so. In this post, I will focus solely on the interviewing part (and leave the rant about recruiters who are paid 1 year of the candidate’s salary to just match buzzwords for another time). I recently stumbled upon an article about interview questions, again, telling you about 'right' answers for such and such questions. There are plenty of such articles on the World Wide Web, full-fledged sites dedicated to this topic an

logging spring boot

Log management in Spring Boot

Logging is for sure not a glamorous subject, but it’s a critical one - at least for DevOps and Ops teams. While there are plenty of material on the Web describing how to change your ASCII banner, there is not much on how to efficiently manage the log output. By default, Spring Boot will output log on the console and not use any file at all. However, it’s possible to tell Spring Boot to log in an output file. At the simplest level, the path where Spring Boot will put the spring.log

spring boot

Designing your own Spring Boot starter – part 2

In the last post, I tried to describe the internal working of Spring Boot starter. It’s now time to develop our own! As an example, we will use XStream, a no-fluff just-stuff XML/JSON (de)serializer offered by Thoughtworks. Readers who only use JAXB and Jackson are advised to have a look at XStream, it’s extremely efficient and its API is quite easy to use. As seen in our last post, the entry-point of a starter lies in the META-INF/spring.factories file. Let’s create such a

spring boot

Designing your own Spring Boot starter - part 1

Since its release, Spring Boot has been a huge success: it boosts developers productivity with its convention over configuration philosophy. However, sometimes, it just feels too magical. I have always been an opponent of autowiring for this exact same reason. And when something doesn’t work, it’s hard to get back on track. This is the reason why I wanted to dig deeper into Spring Boot starter mechanism - to understand every nook and cranny. This post is the first part and will focu

HTML security

Why you shouldn't trust the HTML password input

This week, I wanted to make a simple experiment. For sure, all applications we develop make use of HTTPS to encrypt the login/password but what happens before? Let’s say I typed my login/password but before sending them, I’m called by my colleague and I leave my computer open. My password is protected by the HTML password input, right? It shows stars instead of the real characters. Well, it’s stupidly easy to circumvent this. If you use a developer workstation and have develop

kotlin spring boot vaadin

Playing with Spring Boot, Vaadin and Kotlin

It’s no mystery that I’m a fan of both Spring Boot and Vaadin. When the Spring Boot Vaadin add-on became GA, I was ecstatic. Lately, I became interested in Kotlin, a JVM-based language offered by JetBrains. Thus, I wanted to check how I could develop a small Spring Boot Vaadin demo app in Kotlin - and learn something in the process. Here are my discoveries, in no particular order. Spring needs non-final stuff It seems Spring needs @Configuration classes and @Bean methods to be non