Okay, so sometimes I want to implement some domain...
# getting-started
d
Okay, so sometimes I want to implement some domain object in its own class so it has a nice name (and interface), even tho the domain object has a very basic functionality. E.g. a settings-store (just random example) is basically a key-value map. So I add a map backing the settings. And add some functions to persist it. Sometimes it is even just to make it easier to name things in a sane way instead of working with a Map<String, List<Pair<Something, String>>() But a map offers a lot of useful things. Even just the toString implementation, counting entries and whatnot. (Or a String with its method to lower letters, capitalize etc.) I sometimes write methods in Java that just delegate to methods of the backing object:
Copy code
public int size() {
return backingMap.size();
}
I know in Kotlin I can write it somewhat shorter:
Copy code
fun size() = backingMap.size()
My question: Is this the prefered way of delegating such methods? Or a different approach on how I can give prettier names to things that are basically already existing data types in Kotlin?