[
https://issues.apache.org/jira/browse/FLINK-37665?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17952486#comment-17952486
]
dalongliu commented on FLINK-37665:
-----------------------------------
Merged in master branch: 541d21d3e60ab6c3eee4e37576ce7b47b3e46def
> Simplify DoubleMaximum.clone() Implementation
> ---------------------------------------------
>
> Key: FLINK-37665
> URL: https://issues.apache.org/jira/browse/FLINK-37665
> Project: Flink
> Issue Type: Improvement
> Reporter: Atul Sharma
> Priority: Minor
> Labels: pull-request-available
>
> The current implementation of the clone() method in the DoubleMaximum class
> uses the default constructor and manually sets the max field:
> {code:java}
> // Some comments here
> @Override
> public DoubleMaximum clone() {
> DoubleMaximum clone = new DoubleMaximum();
> clone.max = this.max;
> return clone;
> }
> {code}
> This can be simplified by directly using the existing constructor
> DoubleMaximum(double value) to initialize the cloned object. The proposed
> change is:
> {code:java}
> @Override
> public DoubleMaximum clone() {
> return new DoubleMaximum(this.max);
> }
> {code}
> Benefits of the Change:
> Conciseness: The new implementation is shorter and avoids redundant code.
> Encapsulation: It ensures the object is fully initialized in one step using
> the constructor.
> Readability: The new implementation is easier to read and maintain.
> This change improves the maintainability and clarity of the code without
> altering its functionality.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)