The Daily WTF
As we frequently discuss here, many versions ago, Java added functional programming expressions, which can allow a developer to write very expressive, simple code. Of course, we don’t cover any of those uses, because that’s all fine.
Kevin L used to work for a Fortune 500 company, and that company was full of developers who got very excited about those functional programming features in Java. Very excited. Too excited, if we’re being honest.
For example, if they wanted to check if an object was null, they might do this:
Optional.ofNullable(someObject) .orElse(null)
This code uses the Optional type to wrap a potentially nullable object, someObject, in an option, and then return the value of the object orElse return null. So this line takes an object which may be null, and if it isn’t null, returns the value, otherwise it returns null.
Or, they might do something like:
private boolean detectChanges(String
To read the full article click on the 'post' link at the top.