New Operator Doesnt Stick Out

Alignment on new usage

Firstly, lets align that we should Isolate the Necessary Evil of New Operator to follow SOLID.

Kotlin hides new

Now let's talk about new operator in Kotlin.

new operator is still around there in kotlin, its just hidden away like a rogue that has cloaked itself away.

In java when you use new operator it sticks out at you with highlighted new operator.

img

However, in Kotlin they decided it's not needed and the language can look cleaner without it. Well we are still creating new instances of objects, but now it doesn't stick out as much with default color schemas.

img

With default color schema in Intellij the constructor call doesn't stick out at you anymore since the new operator is gone and the default color schema for Constructor is just inheriting from function call. Letting the constructor hide like a good old function call while its binding us to particular instance.

img

We can try to modify the color schema, but that might be a bit too disruptive to how code looks like, given that things like DescribeSpec are constructors.

img