-
Notifications
You must be signed in to change notification settings - Fork 800
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
Make private fields readonly when possible #2103
Changes from 3 commits
56afb47
1859b24
a26a354
997e9a6
235d36e
a615285
601c58b
ea74b00
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,7 +24,7 @@ namespace OpenTelemetry | |
{ | ||
public class CompositeProcessor<T> : BaseProcessor<T> | ||
{ | ||
private DoublyLinkedListNode head; | ||
private readonly DoublyLinkedListNode head; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I want to get more perspectives regarding this one. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @CodeBlanch do you know if the common practice in C# is to mark something To my knowledge in C++ it is focusing on semantics rather than the actual usage (e.g. const/mutable/volatile). There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @reyang I would say in C# it is based on actual usage. There is an IDE analyzer built into VS that suggests/warns about this case if it can tell you aren't modifying a private field. So you would have to go out of your way/fight the tooling (suppression, disable rule) to stick with the semantic approach. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
As of now, the processors get added in the order of the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
I think in the world where a single user/dev/team controls everything, this should work, and is not an issue from the beginning. In the real world, there might be separation of roles/responsibilities. For example you have an infrastructure team which developed several security or privacy related processors, and that team wants to "prepend" the security/privacy processor before other processors introduced by feature teams. This can be solved by having the infrastructure team establishing some rules (e.g. all the teams should call AddInfrastructureProcessors before adding their stuff), but practically it might be challenging. |
||
private DoublyLinkedListNode tail; | ||
private bool disposed; | ||
|
||
|
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.
Curious, do we consider this as pedantic for example code?