Better Modeling Through Records
28th May, 2022
Hilton Hotel Kozyatağı, İstanbul
We keep seeing more and more functional structures in languages including Java. And immutability is the hallmark of functional programming. record is a new keyword that allows to create a new type in Java called "record classes". Record classes allow developers to easily create bags of data and let the compiler produce necessary plumbing code for them. But their key point is immutability.
We all know that through immutability we can have more speedy applications without having any trouble with concurrency. But what about creating a new immutable type? So do we all start writing record classes instead of regular ones from now on? And records are just going to save us from typing lost of common, plumbing code suc as constructors, equals(), hashCode(), etc. So record classes look like something that standardize Lombok's @Data annotation.
Neither of them are the main idea behind having record classes in Java. In fact some other languages such as C# has recently had record classes. while some other such as Scala and Kotlin had similar structures for longer time.
So the main point of having record classes is to enable developers to better model their problems. And this is going to create lots of opportunities for better programming.
Akin Kaldiroglu is a Software Engineering consultant based in İstanbul Turkey. He has been involved in many enterprise projects in different roles since mid 90s. He started using C and C++ and kept using Java since its arrival. He loves developing software and writing code in Java. He is a fan of clean and object-oriented code. He is trying to be an amateur philosopher. He also gives professional training to developers. email@example.com and @kaldiroglu on Twitter are his main access points.