Been running across this bit of code a lot lately (in java).
if (list != null && list.size() > 0) { } else {
//do stuff
}
I think the original author skipped the day in class where they discussed the OR operator.
Been running across this bit of code a lot lately (in java).
if (list != null && list.size() > 0) { } else {
//do stuff
}
I think the original author skipped the day in class where they discussed the OR operator.
@bjolling said:
@Zemm said:
For file transfers use XML. You can save meta information like datatypes and localization! Wouldn't that make for an excellent database format as well?@dtech said:
CSV isn't a reasonable file transfer format?No, it's a reasonable database format
My meter is broken today. That is sarcasm, yes?
@ratboy667 said:
Actually, I like this code. The conditional reads positively, and is immediately visually correct. The action case is the else, but who cares? !(cond) may be preferred by some, but -- if (list == null || list.size() == 0) { do stuff } is much more prone to error when it reaches maintainance.
No "wtf" here...
I hope I never have to maintain your code if you think that is a good idea.
If you really think (list == null || list.size() == 0) is hard to maintain, then put it in a method and call that. E.g. "if (listIsEmpty(list))...". I could handle that and it reads well. Abusing control structures is not how you write maintainable code.
Been running across this bit of code a lot lately (in java).
if (list != null && list.size() > 0) { } else {
//do stuff
}
I think the original author skipped the day in class where they discussed the OR operator.