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

Reduce code duplication down to 15 lines per piece #2916

Merged
merged 23 commits into from
May 2, 2024

Conversation

c71n93
Copy link
Member

@c71n93 c71n93 commented Mar 4, 2024

Related to #2863


PR-Codex overview

This PR updates Java versions, refactors saving logic, and improves test parameterization.

Detailed summary

  • Updated Java version to 17
  • Refactored saving logic in HmOptional and HmBase
  • Improved test parameterization in UnplaceMojoTest

The following files were skipped due to too many changes: eo-maven-plugin/src/test/java/org/eolang/maven/UnplaceMojoTest.java

✨ Ask PR-Codex anything about this PR by commenting with /codex {your question}

@yegor256
Copy link
Member

yegor256 commented Mar 7, 2024

@c71n93 what's up with this one? Still a draft?

@c71n93
Copy link
Member Author

c71n93 commented Mar 7, 2024

@yegor256 still working on it

@c71n93 c71n93 force-pushed the 2863-reduce-code-duplication-15 branch from a2dd750 to 74c589c Compare March 11, 2024 15:42
@c71n93
Copy link
Member Author

c71n93 commented Mar 11, 2024

@maxonfjvipon could you check this one, please?

Pay attention to PhDecorator class. It seems to me that this is an antipattern, because I turned the decoration into a regular inheritance. This reduced duplication, but I'm not sure about this solution. I could add more not final methods to this class to reduce code duplication even more, but again I'm not sure. @maxonfjvipon Do you have any ideas?

@maxonfjvipon
Copy link
Member

maxonfjvipon commented Mar 14, 2024

@c71n93 when one part of the methods is placed inside abstract class and other part is placed inside concrete class - it's a marker of bad design. If we're not talking about corner cases like mojos, the only right usage of abstract classes is decorating envelopes: https://www.yegor256.com/2017/01/31/decorating-envelopes.html

@maxonfjvipon
Copy link
Member

@c71n93 what's up with this one?

@c71n93
Copy link
Member Author

c71n93 commented Apr 15, 2024

@maxonfjvipon what do you think about Home interface now? Is it acceptable?

@c71n93
Copy link
Member Author

c71n93 commented Apr 15, 2024

@maxonfjvipon all resolved, could you review this one, please?

@@ -86,25 +86,6 @@ public void usesCatcherOutput() {
);
}

@Test
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@c71n93 why was this test removed?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there was 2 same tests with different names

* The data is saved to a file.
* @since 0.32.0
*/
public interface DataSaved {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@c71n93 interface with default methods - it's almost the same as abstract class. You split the logic and keep it in different places.

@c71n93
Copy link
Member Author

c71n93 commented May 2, 2024

@maxonfjvipon could you check this one again, please?

@c71n93
Copy link
Member Author

c71n93 commented May 2, 2024

@yegor256 could you check this one, please?

@yegor256
Copy link
Member

yegor256 commented May 2, 2024

@rultor merge

@rultor
Copy link
Contributor

rultor commented May 2, 2024

@rultor merge

@yegor256 OK, I'll try to merge now. You can check the progress of the merge here

@rultor rultor merged commit e422a9c into objectionary:master May 2, 2024
20 checks passed
@rultor
Copy link
Contributor

rultor commented May 2, 2024

@rultor merge

@yegor256 Done! FYI, the full log is here (took me 17min)

@c71n93 c71n93 deleted the 2863-reduce-code-duplication-15 branch May 6, 2024 09:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants