2 Comments

I'm a fan of the use of Optional vs. using an If/Else statement, as it reads as more expressive that you are expecting a null to be passed and are handling it.

I know that an If/Else statement does the same thing, but at a glance you won't know immediately that the If/Else statement is looking for a `null` or another condition; However with an Optional, you're sounding the alarms that the result could be null.

Thus I feel that the use of Optional is a great showcase of self-describing code. Using Optional means it could be null, end of assumption. While when you are using an If/Else statement, you only know that you could have a condition that you're trying to assert, and said condition could be one of many different types!

Expand full comment