-
I noticed in several places rather than allowing the method to be the condition itself for a condition, there is an explicit comparison to true. Is this necessary? Shouldn't you just take the outcome of isNotBlank() or containsKey() as-is for the condition? What is the benefit of including the == true? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
This is purely a stylistic choice that I've made for this repo, because I think explicitly specifying When I originally first started working on this repo years ago, I didn't follow that convention, I originally used the style you're referring to of |
Beta Was this translation helpful? Give feedback.
This is purely a stylistic choice that I've made for this repo, because I think explicitly specifying
true
orfalse
helps with readability.When I originally first started working on this repo years ago, I didn't follow that convention, I originally used the style you're referring to of
if (someMap.containsKey(key))
. But over the last several years, some of the teams I've worked on have found that during code reviews, some developers would misread conditions likeif (someMap.containsKey(key))
andif (!someMap.containsKey(key))
because the!
can be easily overlooked. By switching to usingif (someMap.containsKey(key) == true)
andif (someMap.containsKey(key) == false)
, we found we had fewe…