You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@dubbo.apache.org by GitBox <gi...@apache.org> on 2021/07/05 08:44:52 UTC
[GitHub] [dubbo] pinxiong commented on pull request #8219: perf: Optimize access permissions of variables
pinxiong commented on pull request #8219:
URL: https://github.com/apache/dubbo/pull/8219#issuecomment-873926267
For Java syntax, it does work well. However, there are two reasons for those changes
+ All of variables with `protected` modifier have defined setters and getters in `AbstractRouter`.
+ It is best to provide only one way to modify the same variables, however, there are two ways to visite those variables:
+ use `protected` modifier to access directly
+ use setter and getter to access
I think the best way is to use setter and getter to access variables, because the interface of `Router` already defines some abstract getter methods, like `Router#getUrl()`, `Router#isForce()`, `Router#getPriority()` etc.
```java
public interface Router extends Comparable<Router> {
......
URL getUrl();
boolean isForce();
int getPriority();
......
@Override
default int compareTo(Router o) {
if (o == null) {
throw new IllegalArgumentException();
}
return Integer.compare(this.getPriority(), o.getPriority());
}
}
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org