Refactor GroupAction to enforce Single Responsibility Principle#79
Open
kagog23 wants to merge 5 commits into
Open
Refactor GroupAction to enforce Single Responsibility Principle#79kagog23 wants to merge 5 commits into
kagog23 wants to merge 5 commits into
Conversation
…upAction - Add JUnit 4, Mockito, JGiven, and AssertJ test dependencies to jhotdraw-core pom.xml - Extract canGroup(DrawingView) and canUngroup(DrawingView) overloads for testability - Add 19 JUnit 4 unit tests covering best case, boundary cases, and Java assert invariants - Add 3 JGiven BDD scenarios (group, ungroup, disabled) with Given/When/Then stage classes Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Change PR trigger from main/master to develop (the project's main branch) - Add push trigger for develop and feature-branch - Pass --settings .maven-settings.xml to both Maven steps for GitHub Packages auth Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Smells removed and patterns applied: - Duplicate Code (UngroupAction constructors): Constructor Chaining — delegate the no-arg constructor to the two-arg constructor - Anonymous Inner Class (AbstractUndoableEdit): Extract Class — replaced with named inner classes GroupUndoableEdit and UngroupUndoableEdit - Wildcard Imports (java.util.*, org.jhotdraw.draw.*): replaced with explicit imports - Repeated view.getDrawing() calls: Introduce Explaining Variable — stored as local Drawing drawing in groupFigures() and ungroupFigures() - Descriptive comment in undo(): removed (code is self-explanatory) - Unchecked cast on prototype.clone(): guarded with Java assert Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
The Issue: GroupAction.java was acting as a "God Class" that handled both grouping and ungrouping via a confusing boolean flag, which violated the Single Responsibility Principle.
The Fix: Extracted the unpackaging logic into a standalone UngroupAction.java class.
Downstream Cleanup: Fixed the inheritance ripple effect in SplitAction.java and CombineAction.java by removing invalid @OverRide tags.