You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the current behavior of what you're trying to improve. If your enhancement request related to a problem, please also describe the problem.
It can be hard to tell what objects can be null and what shouldn't be.
Describe the improvement you'd like
I think adding JetBrains Annotations could be helpful to make some things in the code more clear. Some nice ones are @Nullable, @NotNull, and @Contract, especially for classes that are meant to be used in more than just one puzzle. @Contract can be used to specify whether a method is pure and whether it mutates method parameters, along with describing other behaviors of a method. Another benefit is that IntelliJ can generate warnings based on the annotations, for example if you pass a nullable object to a method parameter marked @NotNull without checking if it's null first.
Using both @Nullable and @NotNull isn't necessary, if this request is approved I think one or the other should be used and added to the developer guidelines. I think using @Nullable and assuming @NotNull is good, but either way works.
Describe alternatives you've considered
Commenting code is another way to show what can be null and describe method behaviors, but I think annotations are more clear and they can also generate warnings in IntelliJ.
Additional Context
This wouldn't change any behavior of the code, it would just add some nice documentation and help prevent errors and bugs.
The text was updated successfully, but these errors were encountered:
Describe the current behavior of what you're trying to improve. If your enhancement request related to a problem, please also describe the problem.
It can be hard to tell what objects can be null and what shouldn't be.
Describe the improvement you'd like
I think adding JetBrains Annotations could be helpful to make some things in the code more clear. Some nice ones are
@Nullable
,@NotNull
, and@Contract
, especially for classes that are meant to be used in more than just one puzzle.@Contract
can be used to specify whether a method is pure and whether it mutates method parameters, along with describing other behaviors of a method. Another benefit is that IntelliJ can generate warnings based on the annotations, for example if you pass a nullable object to a method parameter marked@NotNull
without checking if it's null first.Using both
@Nullable
and@NotNull
isn't necessary, if this request is approved I think one or the other should be used and added to the developer guidelines. I think using@Nullable
and assuming@NotNull
is good, but either way works.Describe alternatives you've considered
Commenting code is another way to show what can be null and describe method behaviors, but I think annotations are more clear and they can also generate warnings in IntelliJ.
Additional Context
This wouldn't change any behavior of the code, it would just add some nice documentation and help prevent errors and bugs.
The text was updated successfully, but these errors were encountered: