Skip to content

Refactor GroupAction to enforce Single Responsibility Principle#79

Open
kagog23 wants to merge 5 commits into
sweat-tek:developfrom
kagog23:feature-branch
Open

Refactor GroupAction to enforce Single Responsibility Principle#79
kagog23 wants to merge 5 commits into
sweat-tek:developfrom
kagog23:feature-branch

Conversation

@kagog23

@kagog23 kagog23 commented Jun 11, 2026

Copy link
Copy Markdown

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.

Karlitos911 and others added 5 commits June 11, 2026 18:53
…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>
@kagog23 kagog23 closed this Jun 11, 2026
@kagog23 kagog23 reopened this Jun 11, 2026
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.

2 participants