Skip to content
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

[Enhancement] Do some code optimization.[MessageQueue] #3827

Closed
1 of 2 tasks
Alonexc opened this issue Apr 27, 2023 · 0 comments · Fixed by #3987
Closed
1 of 2 tasks

[Enhancement] Do some code optimization.[MessageQueue] #3827

Alonexc opened this issue Apr 27, 2023 · 0 comments · Fixed by #3987
Labels
enhancement New feature or request

Comments

@Alonexc
Copy link
Contributor

Alonexc commented Apr 27, 2023

Search before asking

  • I had searched in the issues and found no similar issues.

Enhancement Request

image
image
image
located at:
eventmesh-storage-plugin/eventmesh-storage-standalone/src/main/java/org/apache/eventmesh/storage/standalone/broker/MessageQueue.java line 32,68,87,105,129,152,178,
eventmesh-storage-plugin/eventmesh-storage-standalone/src/test/java/org/apache/eventmesh/storage/standalone/broker/MessageQueueTest.java line 46,53,60,67,74,81,94
analysis and explanation:
a. Public class variable fields do not respect the encapsulation principle and has three main disadvantages:
Additional behavior such as validation cannot be added.
The internal representation is exposed, and cannot be changed afterwards.
Member values are subject to change from anywhere in the code and may not meet the programmer’s assumptions.
By using private attributes and accessor methods (set and get), unauthorized modifications are prevented.
b. Overriding or shadowing a variable declared in an outer scope can strongly impact the readability, and therefore the maintainability, of a piece of code. Further, it could lead maintainers to introduce bugs because they think they’re using one variable but are really using another.

Describe the solution you'd like

a. Change to use the private final modifier.
image
image
image

b. 'lock' rename.
image

Are you willing to submit PR?

  • Yes I am willing to submit a PR!
@Alonexc Alonexc added the enhancement New feature or request label Apr 27, 2023
Ishaan29 added a commit to Ishaan29/eventmesh that referenced this issue May 20, 2023
Changed Access modifier of `items[]`
Added getters for the same
Changed Breaking tests
xwm1992 pushed a commit that referenced this issue May 30, 2023
* Issue #3827

Changed Access modifier of `items[]`
Added getters for the same
Changed Breaking tests

* Renamed reentrant lock inside method scopes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant