Skip to content

Implement View Helper pattern#3278

Merged
iluwatar merged 13 commits intoiluwatar:masterfrom
e5LA:1263-view-helper
Feb 8, 2026
Merged

Implement View Helper pattern#3278
iluwatar merged 13 commits intoiluwatar:masterfrom
e5LA:1263-view-helper

Conversation

@e5LA
Copy link
Contributor

@e5LA e5LA commented May 13, 2025

What does this PR do?

This PR implements the View Helper design pattern to improve the separation of concerns within the application. It introduces a View Helper class responsible for handling data formatting and processing tasks. The Controller is updated to delegate relevant responsibilities to the View Helper, and the View is refactored to consume the prepared data, resulting in cleaner, more maintainable code.

Fixes #1263

@github-actions
Copy link

github-actions bot commented May 13, 2025

PR Summary

Implemented the View Helper design pattern by adding a new view-helper module. Introduced Product, ProductViewModel, and ProductViewHelper to format data; included ProductController to coordinate between data, helper, and view; ConsoleProductView renders the formatted data. Updated Maven to expose the new module. Added unit tests AppTest and ProductViewHelperTest and included diagrams and README. Fixes #1263.

Changes

File Summary
pom.xml Updated root POM to include the new 'view-helper' module in the build, aligning the multi-module structure.
view-helper/README.md Added documentation describing the View Helper pattern, its intent, sample usage, and benefits for clean presentation logic.
view-helper/etc/view-helper-sequence-diagram.png Included a sequence diagram image illustrating the View Helper flow among Client, Controller, ViewHelper, View, and Product components.
view-helper/etc/view-helper-sequence-diagram.puml Provided PlantUML sequence diagram (.puml) detailing interactions in the View Helper flow.
view-helper/etc/view-helper.png Added view-helper diagram in PNG format for quick reference.
view-helper/etc/view-helper.puml Provided PlantUML module diagram (.puml) for the View Helper pattern structure.
view-helper/pom.xml Defined the new Maven module 'view-helper' with dependencies and build setup.
view-helper/src/main/java/com/iluwatar/viewhelper/App.java Main application class simulating the View Helper workflow: create Product, format via ProductViewHelper, and render via ConsoleProductView through ProductController.
view-helper/src/main/java/com/iluwatar/viewhelper/ConsoleProductView.java Implemented ConsoleProductView to render ProductViewModel to the console.
view-helper/src/main/java/com/iluwatar/viewhelper/Product.java Defined Product as a domain object (record) used by the View Helper pipeline.
view-helper/src/main/java/com/iluwatar/viewhelper/ProductController.java Controller delegates to ProductViewHelper for formatting and to ConsoleProductView for rendering.
view-helper/src/main/java/com/iluwatar/viewhelper/ProductViewHelper.java Implemented ProductViewHelper to format a Product into a ProductViewModel.
view-helper/src/main/java/com/iluwatar/viewhelper/ProductViewModel.java Holds formatted display data for a Product in ProductViewModel.
view-helper/src/main/java/com/iluwatar/viewhelper/View.java View interface used for rendering models.
view-helper/src/main/java/com/iluwatar/viewhelper/ViewHelper.java ViewHelper interface to prepare a view model from a source object.
view-helper/src/test/java/com/iluwatar/viewhelper/AppTest.java Test ensuring App.main runs without throwing exceptions.
view-helper/src/test/java/com/iluwatar/viewhelper/ProductViewHelperTest.java Tests for ProductViewHelper formatting logic (with and without discount explained).

autogenerated by presubmit.ai

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

LGTM!

Review Summary

Commits Considered (11)
  • 3e1263e: Merge remote-tracking branch 'upstream/master' into 1263-view-helper

Conflicts:

pom.xml

Files Processed (17)
  • pom.xml (2 hunks)
  • view-helper/README.md (1 hunk)
  • view-helper/etc/view-helper-sequence-diagram.png (0 hunks)
  • view-helper/etc/view-helper-sequence-diagram.puml (1 hunk)
  • view-helper/etc/view-helper.png (0 hunks)
  • view-helper/etc/view-helper.puml (1 hunk)
  • view-helper/pom.xml (1 hunk)
  • view-helper/src/main/java/com/iluwatar/viewhelper/App.java (1 hunk)
  • view-helper/src/main/java/com/iluwatar/viewhelper/ConsoleProductView.java (1 hunk)
  • view-helper/src/main/java/com/iluwatar/viewhelper/Product.java (1 hunk)
  • view-helper/src/main/java/com/iluwatar/viewhelper/ProductController.java (1 hunk)
  • view-helper/src/main/java/com/iluwatar/viewhelper/ProductViewHelper.java (1 hunk)
  • view-helper/src/main/java/com/iluwatar/viewhelper/ProductViewModel.java (1 hunk)
  • view-helper/src/main/java/com/iluwatar/viewhelper/View.java (1 hunk)
  • view-helper/src/main/java/com/iluwatar/viewhelper/ViewHelper.java (1 hunk)
  • view-helper/src/test/java/com/iluwatar/viewhelper/AppTest.java (1 hunk)
  • view-helper/src/test/java/com/iluwatar/viewhelper/ProductViewHelperTest.java (1 hunk)
Actionable Comments (0)
Skipped Comments (0)

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

LGTM!

Review Summary

Commits Considered (1)
Files Processed (16)
  • pom.xml (2 hunks)
  • view-helper/README.md (1 hunk)
  • view-helper/etc/view-helper-sequence-diagram.png (0 hunks)
  • view-helper/etc/view-helper-sequence-diagram.puml (1 hunk)
  • view-helper/etc/view-helper.png (0 hunks)
  • view-helper/etc/view-helper.puml (1 hunk)
  • view-helper/src/main/java/com/iluwatar/viewhelper/App.java (1 hunk)
  • view-helper/src/main/java/com/iluwatar/viewhelper/ConsoleProductView.java (1 hunk)
  • view-helper/src/main/java/com/iluwatar/viewhelper/Product.java (1 hunk)
  • view-helper/src/main/java/com/iluwatar/viewhelper/ProductController.java (1 hunk)
  • view-helper/src/main/java/com/iluwatar/viewhelper/ProductViewHelper.java (1 hunk)
  • view-helper/src/main/java/com/iluwatar/viewhelper/ProductViewModel.java (1 hunk)
  • view-helper/src/main/java/com/iluwatar/viewhelper/View.java (1 hunk)
  • view-helper/src/main/java/com/iluwatar/viewhelper/ViewHelper.java (1 hunk)
  • view-helper/src/test/java/com/iluwatar/viewhelper/AppTest.java (1 hunk)
  • view-helper/src/test/java/com/iluwatar/viewhelper/ProductViewHelperTest.java (1 hunk)
Actionable Comments (0)
Skipped Comments (0)

@sonarqubecloud
Copy link

Quality Gate Failed Quality Gate failed

Failed conditions
7 Security Hotspots
E Reliability Rating on New Code (required ≥ A)
E Security Rating on New Code (required ≥ A)

See analysis details on SonarQube Cloud

Catch issues before they fail your Quality Gate with our IDE extension SonarQube for IDE

@github-actions
Copy link

This PR is stale because it has been open 60 days with no activity.

@github-actions github-actions bot added the Stale label Jul 13, 2025
Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

LGTM!

Review Summary

Commits Considered (1)
  • 26731ae: Merge branch 'master' into 1263-view-helper
Files Processed (1)
  • pom.xml (2 hunks)
Actionable Comments (0)
Skipped Comments (1)
  • pom.xml [246-246]

    enhancement: "Introduce new module view-helper; ensure module is self-contained."

@sonarqubecloud
Copy link

sonarqubecloud bot commented Feb 8, 2026

@iluwatar iluwatar merged commit a3fcc63 into iluwatar:master Feb 8, 2026
2 checks passed
@iluwatar
Copy link
Owner

iluwatar commented Feb 8, 2026

@all-contributors please add @e5LA for code

@allcontributors
Copy link
Contributor

@iluwatar

@e5LA already contributed before to code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

View Helper pattern

2 participants