Technical Debt: Cyclic dependency between LoadBalanceStats and ServerStats #470
+87
−87
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
As explained in #465 , a cyclic dependency between LoadBalancerStats and ServerStats has created a persistent negative impact on developers when working in these classes. We have computed this negative impact to be as high as 12% in some commits, with a persistent effect of an average 4.5%
Specifically, these classes are very tightly coupled by their shared dynamic configuration attributes. The UnboxedIntProperty attributes of both this classes are reference to the same objects. This makes the source code more difficult to maintain and therefore these needs to be encapsulated in its own abstraction.
Changes:
We introduce a new class called ConfigStats that encapsulate these attributes. Its associated methods others have been moved from LoadBalancer to this new class. Instances of both LoadBalancer and ServerStats own a ConfigStats object which they use to access the now encapsulated UnboxedIntProperty using primitive getter/setters. Thus, the underlying dynamic configuration logic is effectively abstracted away and the cyclic dependency is dissolved.