-
Notifications
You must be signed in to change notification settings - Fork 43
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add assert
tag
#155
Add assert
tag
#155
Conversation
It's fairly common in the mod dev channels to see people using asserts when they shouldn't. A quick tag to explain why they shouldn't be used and what to use instead would be beneficial.
Assertions are fine? Sure, they are meant more for debugging, but it's not that bad. |
The tag is more for letting mod devs that dont understand that it wont give the logic they want and to drive better code style with proper null checks and defaults |
In any case the tag is wrong given it says it'll crash if assertions are disabled (default), when they will simply be ignored. |
the assertion being ignored will lead to undefined behavior, generally a NPE which will crash |
I think an important distinction to make is that assertions are fine when used correctly, which unfortunately is rarely the case when people use them in their mods. In any case, since they're disabled in the JVM by default, to achieve what the assertion did in dev, null-checking needs to be used in prod, at which point null-checking should've just been used in the first place. Oracle's stance on assertions is relevant too.
yeah, this is what I meant. I suppose the case is actually "when the assertion would normally fail, but assertions are disabled." I'll amend the tag. |
It's fairly common in the mod dev channels to see people using asserts when they shouldn't. A quick tag to explain why they shouldn't be used and what to use instead would be beneficial.