This post is the beginning of a series about functional software
architecture in Kotlin. Its material originally comes from a collaboration
between Active Group and Blume2000, where
we consulted them on the development of their web shop. I wrote this
post together with Benedikt
Stemmildt, who was CTO at Blume2000
at the time.
This post is about data validation. We want to ensure that objects in our
program are „valid,“ meaning they satisfy arbitrary
consistency criteria without which our software won‘t function.
My colleague Marco Schneider already presented abstractions for this
in Haskell in an
earlier post.
The same ideas can also be transferred to Kotlin — with some
compromises. In this post, we‘ll tackle the topic anew, specifically
how we can help an object-oriented perspective using functional
techniques. So it‘s not necessary to read the
Haskell post. (We still warmly recommend the post, as it particularly
describes the concept of Applicative, which is impractical in
Kotlin.) However, basic Kotlin knowledge is assumed.
Read on...