-
-
Notifications
You must be signed in to change notification settings - Fork 308
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鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
ref: Make description in SpanProtocol nonnull #1059
Conversation
SentrySpanProtocol.startChildWithOperation has an overload without a description if you don't want to specify a description. We don't need the description to be nullable.
`Instructions and example for changelog`$
To the changelog entry, please add a link to this PR (consider a more descriptive message):` - Make description in SpanProtocol nonnull(#1059)
|
Codecov Report
@@ Coverage Diff @@
## master #1059 +/- ##
==========================================
+ Coverage 94.14% 94.20% +0.06%
==========================================
Files 93 93
Lines 4115 4127 +12
==========================================
+ Hits 3874 3888 +14
+ Misses 241 239 -2
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was a conscious decision and we discussed it on the PR
The problem with this (and I hit this problem using the API in .NET) is that if you are calling this with a "string variable" for description
which you don't know if it's null or not, you need to do a If
check to call one overload or the other.
This code was done in .NET (the way you're proposing here) and it's just not a good API.
description
is nullable, so makes sense and it's a better usability to have the overload be nullable
Wouldn't you agree that you don't see
I also don't see this often in standard libraries, so for me, it looks weird. I'm a huge fan of the null safety for example in Kotlin and for me, it makes sense to use it rarely. In Swift per default, every value is
You would have this problem with every method overload where the parameters are |
obviously, this is a trade-off, both use cases here have pros/cons, what makes me decide if a nullable field should have a non-nullable field in the method param is if this could be used at runtime dynamically, eg description is likely being used with a SQL query or literally anything else, including a request or response value, which could be null/empty or not, so it's just easier to allow them doing do(x, y) instead of if (x & y) call do(x, y) instead do(x). |
I'm late to the discussion but I agree that if the property can be null, its value in any method should allow null. |
馃摐 Description
SentrySpanProtocol.startChildWithOperation has an overload without a
description if you don't want to specify a description. We don't need
the description to be nullable.
馃挕 Motivation and Context
Improves the API.
馃挌 How did you test it?
CI.
馃摑 Checklist
馃敭 Next steps