I'm wondering what are good cases for WET (Write Everything Twice (or more)) code. I could kind of see arguments on both sides for this particular case:
Comments
Log in with your Bluesky account to leave a comment
Meh, pointless. I don't trust these utility functions, you never know what they handle. It could include empty array/object handling as nullish if the author is Python lover, for example. It just wastes my time with having to check contents/docs
We have a saying in Russia, roughly translated: "The shed has "Dick" written on it, but there's actually firewood inside" =P I don't trust that the person who wrote the function knew what they were doing. Also, your naming is great, but there's equal chance it would be called `isEmpty`.
Kinda difficult with the example because a nullish check is easy and straightforward. It’s more work to go and find the utility function and import it than to just use a thing == null test
That's exactly why I'm using this example. Where's the line?
Is it number of times this check is made? Does that number change based on the ease of writing the conditional check? Does it change on how discoverable it is?
i mean in this case I think the function is strictly worse., it’s not shorter or faster and it’s enough of an idiom that I think you could say the semantic value of the named function is less than something more complicated
Comments
What are the factors that sway your decision? Where is the line between one way or another for you?
or causing a bug because one of them wasn't updated
I was curious what people would think about this. I've used both patterns, don't really mind either.
Is it number of times this check is made? Does that number change based on the ease of writing the conditional check? Does it change on how discoverable it is?
However, it is shorter, even if it's only a few characters, so I won't budge on that. If your variable names are longer, you save even more.
I'm not saying isNullish is better either, just curious