diff --git a/pom.xml b/pom.xml
index d9667ed354d2..299d6da9d3aa 100644
--- a/pom.xml
+++ b/pom.xml
@@ -71,7 +71,6 @@
Java Design Patterns
-
abstract-document
abstract-factory
active-object
@@ -241,11 +240,11 @@
update-method
value-object
version-number
+ view-helper
virtual-proxy
visitor
- backpressure
- actor-model
-
+ backpressure
+ actor-model
diff --git a/view-helper/README.md b/view-helper/README.md
new file mode 100644
index 000000000000..fbc93acba6fd
--- /dev/null
+++ b/view-helper/README.md
@@ -0,0 +1,98 @@
+---
+title: "View Helper Pattern in Java: Simplifying Presentation Logic in MVC Applications"
+shortTitle: View Helper
+description: "Discover the View Helper Design Pattern in Java, a powerful technique for separating view-related logic from business logic in MVC-based web applications. This pattern enhances maintainability, reusability, and testability by delegating complex UI operations to reusable helper components. Ideal for developers aiming to keep views clean and focused on presentation."
+category: Architectural
+language: en
+tag:
+ - Architecture
+ - Presentation
+ - Decoupling
+ - Code reuse
+---
+
+## Intent of View Helper Design Pattern
+The View Helper Design Pattern separates presentation logic from the view by delegating complex UI tasks — like formatting or conditional display — to reusable helper components. This keeps views clean, promotes reuse, and aligns with the MVC principle of separating concerns between the view and the business logic.
+
+## Detailed Explanation with Real‑World Analogy
+Real‑world example
+> Imagine you're putting together a slideshow for a business presentation. You focus on arranging the slides, choosing the layout, and telling the story. But for tasks like resizing images, formatting charts, or converting data into visual form, you use tools or templates that automate those parts.
+>
+> In this analogy, you are the view, and the tools/templates are the helpers. They handle the heavy lifting behind the scenes so you can concentrate on the presentation. Similarly, in the View Helper pattern, the view delegates logic-heavy tasks—such as formatting or conditionally displaying data—to helper classes, keeping the view layer clean and presentation-focused.
+
+### In plain words
+> The View Helper pattern is about keeping your UI code clean by moving any logic—like formatting, calculations, or decision-making—into separate helper classes. Instead of stuffing all the logic into the HTML or template files, you delegate it to helpers, so the view just focuses on showing the final result.
+
+### Sequence diagram
+
+
+## Programmatic Example of View Helper Pattern in Java
+Raw domain object
+```java
+public record Product(String name, BigDecimal price, LocalDate releaseDate, boolean discounted) {}
+```
+
+View model object for display
+```java
+public record ProductViewModel(String name, String price, String releasedDate) {}
+```
+
+View Helper formats data for display
+```java
+class ProductViewHelper implements ViewHelper {
+
+ private static final String DISCOUNT_TAG = " (ON SALE)";
+
+ public ProductViewModel prepare(Product product) {
+ var displayName = product.name() + (product.discounted() ? DISCOUNT_TAG : "");
+ var priceWithCurrency = NumberFormat.getCurrencyInstance(US).format(product.price());
+ var formattedDate = product.releaseDate().format(ISO_DATE);
+
+ return new ProductViewModel(displayName, priceWithCurrency, formattedDate);
+ }
+}
+```
+
+View renders the formatted data
+```java
+public class ConsoleProductView implements View {
+
+ @Override
+ public void render(ProductViewModel productViewModel) {
+ LOGGER.info(productViewModel.toString());
+ }
+}
+```
+The `App.java` class simulates how the View Helper pattern works in a real application. It starts with a raw `Product` object containing unformatted data.
+Then it:
+1. Initializes a helper (`ProductViewHelper`) to format the product data for display.
+1. Creates a view (`ConsoleProductView`) to render the formatted data.
+1. Uses a controller (`ProductController`) to coordinate the flow between raw data, helper logic, and view rendering.
+
+Finally, it simulates a user request by passing the product to the controller, which prepares the view model using the helper and displays it using the view. This demonstrates a clean separation between data, presentation logic, and rendering.
+
+## When to Use the View Helper Pattern in Java
+Use the View Helper pattern when your view layer starts containing logic such as formatting data, applying conditional styles, or transforming domain objects for display. It's especially useful in MVC architectures where you want to keep views clean and focused on rendering, while delegating non-trivial presentation logic to reusable helper classes. This pattern helps improve maintainability, testability, and separation of concerns in your application's UI layer.
+
+## Real‑World Uses of View Helper Pattern in Java
+The View Helper pattern is widely used in web frameworks that follow the MVC architecture. In Java-based web applications (e.g., JSP, Spring MVC), it's common to use helper classes or utility methods to format dates, currencies, or apply conditional logic before rendering views. Technologies like Thymeleaf or JSF often rely on custom tags or expression helpers to achieve the same effect.
+
+## Benefits and Trade‑offs
+Benefits:
+* Separation of concerns: Keeps view templates clean by moving logic into dedicated helpers.
+* Reusability: Common formatting and display logic can be reused across multiple views.
+* Improved maintainability: Easier to update presentation logic without touching the view.
+* Testability: Helpers can be unit tested independently from the UI layer.
+
+Trade‑offs:
+* Added complexity: Introduces extra classes, which may feel unnecessary for very simple views.
+* Overuse risk: Excessive use of helpers can spread logic thinly across many files, making it harder to trace behavior.
+* Tight coupling risk: If not designed carefully, helpers can become tightly coupled to specific views or data formats.
+
+## Related Java Design Patterns
+* [Model-View-Controller (MVC)](https://java-design-patterns.com/patterns/model-view-controller/): View Helper supports the View layer in MVC by offloading logic from the view to helper classes.
+* [Template Method](https://java-design-patterns.com/patterns/template-method/): Can structure the steps of rendering or data transformation, with helpers handling specific formatting tasks.
+* [Data Transfer Object (DTO)](https://java-design-patterns.com/patterns/data-transfer-object/): Often used alongside View Helper when transferring raw data that needs formatting before being displayed.
+
+## References & Credits
+* [Core J2EE Patterns: View Helper.](https://www.oracle.com/java/technologies/viewhelper.html)
diff --git a/view-helper/etc/view-helper-sequence-diagram.png b/view-helper/etc/view-helper-sequence-diagram.png
new file mode 100644
index 000000000000..22e53c6b8afe
Binary files /dev/null and b/view-helper/etc/view-helper-sequence-diagram.png differ
diff --git a/view-helper/etc/view-helper-sequence-diagram.puml b/view-helper/etc/view-helper-sequence-diagram.puml
new file mode 100644
index 000000000000..d5be27e51510
--- /dev/null
+++ b/view-helper/etc/view-helper-sequence-diagram.puml
@@ -0,0 +1,15 @@
+@startuml
+actor Client
+participant Controller
+participant ViewHelper
+participant View
+participant Product
+participant ProductViewModel
+
+Client -> Controller : handle(product)
+Controller -> ViewHelper : prepare(product)
+ViewHelper -> Product : access data
+ViewHelper -> ProductViewModel : return formatted view model
+Controller -> View : render(viewModel)
+View -> Console : display output
+@enduml
\ No newline at end of file
diff --git a/view-helper/etc/view-helper.png b/view-helper/etc/view-helper.png
new file mode 100644
index 000000000000..9550b80d7acb
Binary files /dev/null and b/view-helper/etc/view-helper.png differ
diff --git a/view-helper/etc/view-helper.puml b/view-helper/etc/view-helper.puml
new file mode 100644
index 000000000000..cbc4a57d31ff
--- /dev/null
+++ b/view-helper/etc/view-helper.puml
@@ -0,0 +1,45 @@
+@startuml
+package com.iluwatar.viewhelper {
+ interface View {
+ +render(T model)
+ }
+
+ interface ViewHelper {
+ +prepare(S source): T
+ }
+
+ class Product {
+ -name: String
+ -price: BigDecimal
+ -releaseDate: LocalDate
+ -discounted: boolean
+ }
+
+ class ProductViewModel {
+ -name: String
+ -price: String
+ -releasedDate: String
+ }
+
+ class ProductViewHelper {
+ +prepare(Product): ProductViewModel
+ }
+
+ class ConsoleProductView {
+ +render(ProductViewModel)
+ }
+
+ class ProductController {
+ -helper: ViewHelper
+ -view: View
+ +handle(Product)
+ }
+}
+Product --> ProductViewHelper
+ProductViewHelper ..|> ViewHelper
+ConsoleProductView ..|> View
+ProductViewHelper --> ProductViewModel
+ProductController --> ProductViewHelper
+ProductController --> ConsoleProductView
+
+@enduml
\ No newline at end of file
diff --git a/view-helper/pom.xml b/view-helper/pom.xml
new file mode 100644
index 000000000000..e2f3afca3a08
--- /dev/null
+++ b/view-helper/pom.xml
@@ -0,0 +1,70 @@
+
+
+
+ 4.0.0
+
+ com.iluwatar
+ java-design-patterns
+ 1.26.0-SNAPSHOT
+
+ view-helper
+
+
+ org.slf4j
+ slf4j-api
+
+
+ ch.qos.logback
+ logback-classic
+
+
+ org.junit.jupiter
+ junit-jupiter-engine
+ test
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-assembly-plugin
+
+
+
+
+
+ com.iluwatar.value.object.App
+
+
+
+
+
+
+
+
+
diff --git a/view-helper/src/main/java/com/iluwatar/viewhelper/App.java b/view-helper/src/main/java/com/iluwatar/viewhelper/App.java
new file mode 100644
index 000000000000..e427bc8f5e9b
--- /dev/null
+++ b/view-helper/src/main/java/com/iluwatar/viewhelper/App.java
@@ -0,0 +1,52 @@
+/*
+ * This project is licensed under the MIT license. Module model-view-viewmodel is using ZK framework licensed under LGPL (see lgpl-3.0.txt).
+ *
+ * The MIT License
+ * Copyright © 2014-2022 Ilkka Seppälä
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+package com.iluwatar.viewhelper;
+
+import java.math.BigDecimal;
+import java.time.LocalDate;
+
+/** The main application class that sets up and runs the View Helper pattern demo. */
+public class App {
+ /**
+ * The entry point of the application.
+ *
+ * @param args the command line arguments
+ */
+ public static void main(String[] args) {
+ // Raw Product data (no formatting, no UI tags)
+ var product =
+ new Product(
+ "Design patterns book", new BigDecimal("18.90"), LocalDate.of(2025, 4, 19), true);
+
+ // Create view, viewHelper and viewHelper
+ var helper = new ProductViewHelper();
+ var view = new ConsoleProductView();
+ var controller = new ProductController(helper, view);
+
+ // Handle “request”
+ controller.handle(product);
+ }
+}
diff --git a/view-helper/src/main/java/com/iluwatar/viewhelper/ConsoleProductView.java b/view-helper/src/main/java/com/iluwatar/viewhelper/ConsoleProductView.java
new file mode 100644
index 000000000000..7f215a7514f6
--- /dev/null
+++ b/view-helper/src/main/java/com/iluwatar/viewhelper/ConsoleProductView.java
@@ -0,0 +1,36 @@
+/*
+ * This project is licensed under the MIT license. Module model-view-viewmodel is using ZK framework licensed under LGPL (see lgpl-3.0.txt).
+ *
+ * The MIT License
+ * Copyright © 2014-2022 Ilkka Seppälä
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+package com.iluwatar.viewhelper;
+
+import lombok.extern.slf4j.Slf4j;
+
+/** Renders {@link ProductViewModel} to the console. */
+@Slf4j
+public class ConsoleProductView implements View {
+ @Override
+ public void render(ProductViewModel productViewModel) {
+ LOGGER.info(productViewModel.toString());
+ }
+}
diff --git a/view-helper/src/main/java/com/iluwatar/viewhelper/Product.java b/view-helper/src/main/java/com/iluwatar/viewhelper/Product.java
new file mode 100644
index 000000000000..a0a75cf24188
--- /dev/null
+++ b/view-helper/src/main/java/com/iluwatar/viewhelper/Product.java
@@ -0,0 +1,31 @@
+/*
+ * This project is licensed under the MIT license. Module model-view-viewmodel is using ZK framework licensed under LGPL (see lgpl-3.0.txt).
+ *
+ * The MIT License
+ * Copyright © 2014-2022 Ilkka Seppälä
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+package com.iluwatar.viewhelper;
+
+import java.math.BigDecimal;
+import java.time.LocalDate;
+
+/** Definition of product. */
+public record Product(String name, BigDecimal price, LocalDate releaseDate, boolean discounted) {}
diff --git a/view-helper/src/main/java/com/iluwatar/viewhelper/ProductController.java b/view-helper/src/main/java/com/iluwatar/viewhelper/ProductController.java
new file mode 100644
index 000000000000..836f34a33167
--- /dev/null
+++ b/view-helper/src/main/java/com/iluwatar/viewhelper/ProductController.java
@@ -0,0 +1,49 @@
+/*
+ * This project is licensed under the MIT license. Module model-view-viewmodel is using ZK framework licensed under LGPL (see lgpl-3.0.txt).
+ *
+ * The MIT License
+ * Copyright © 2014-2022 Ilkka Seppälä
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+package com.iluwatar.viewhelper;
+
+/**
+ * Controller delegates a {@link Product} to {@link ProductViewHelper} and then to {@link
+ * ConsoleProductView}.
+ */
+public class ProductController {
+
+ private final ViewHelper viewHelper;
+ private final View view;
+
+ public ProductController(
+ ViewHelper viewHelper, View view) {
+ this.viewHelper = viewHelper;
+ this.view = view;
+ }
+
+ /**
+ * Passes the product to the helper for formatting and then forwards formatted product to the
+ * view.
+ */
+ public void handle(Product product) {
+ view.render(viewHelper.prepare(product));
+ }
+}
diff --git a/view-helper/src/main/java/com/iluwatar/viewhelper/ProductViewHelper.java b/view-helper/src/main/java/com/iluwatar/viewhelper/ProductViewHelper.java
new file mode 100644
index 000000000000..4c739e9f14a8
--- /dev/null
+++ b/view-helper/src/main/java/com/iluwatar/viewhelper/ProductViewHelper.java
@@ -0,0 +1,45 @@
+/*
+ * This project is licensed under the MIT license. Module model-view-viewmodel is using ZK framework licensed under LGPL (see lgpl-3.0.txt).
+ *
+ * The MIT License
+ * Copyright © 2014-2022 Ilkka Seppälä
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+package com.iluwatar.viewhelper;
+
+import static java.time.format.DateTimeFormatter.ISO_DATE;
+import static java.util.Locale.US;
+
+import java.text.NumberFormat;
+
+/** Formats a {@link Product} into a {@link ProductViewModel}. */
+public class ProductViewHelper implements ViewHelper {
+
+ private static final String DISCOUNT_TAG = " ON SALE";
+
+ @Override
+ public ProductViewModel prepare(Product product) {
+ var displayName = product.name() + (product.discounted() ? DISCOUNT_TAG : "");
+ var priceWithCurrency = NumberFormat.getCurrencyInstance(US).format(product.price());
+ var formattedDate = product.releaseDate().format(ISO_DATE);
+
+ return new ProductViewModel(displayName, priceWithCurrency, formattedDate);
+ }
+}
diff --git a/view-helper/src/main/java/com/iluwatar/viewhelper/ProductViewModel.java b/view-helper/src/main/java/com/iluwatar/viewhelper/ProductViewModel.java
new file mode 100644
index 000000000000..b133fc071da1
--- /dev/null
+++ b/view-helper/src/main/java/com/iluwatar/viewhelper/ProductViewModel.java
@@ -0,0 +1,28 @@
+/*
+ * This project is licensed under the MIT license. Module model-view-viewmodel is using ZK framework licensed under LGPL (see lgpl-3.0.txt).
+ *
+ * The MIT License
+ * Copyright © 2014-2022 Ilkka Seppälä
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+package com.iluwatar.viewhelper;
+
+/** Class defining formatted display data of a {@link Product}. */
+public record ProductViewModel(String name, String price, String releasedDate) {}
diff --git a/view-helper/src/main/java/com/iluwatar/viewhelper/View.java b/view-helper/src/main/java/com/iluwatar/viewhelper/View.java
new file mode 100644
index 000000000000..7bc822166885
--- /dev/null
+++ b/view-helper/src/main/java/com/iluwatar/viewhelper/View.java
@@ -0,0 +1,30 @@
+/*
+ * This project is licensed under the MIT license. Module model-view-viewmodel is using ZK framework licensed under LGPL (see lgpl-3.0.txt).
+ *
+ * The MIT License
+ * Copyright © 2014-2022 Ilkka Seppälä
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+package com.iluwatar.viewhelper;
+
+public interface View {
+
+ void render(V data);
+}
diff --git a/view-helper/src/main/java/com/iluwatar/viewhelper/ViewHelper.java b/view-helper/src/main/java/com/iluwatar/viewhelper/ViewHelper.java
new file mode 100644
index 000000000000..68756f46585d
--- /dev/null
+++ b/view-helper/src/main/java/com/iluwatar/viewhelper/ViewHelper.java
@@ -0,0 +1,29 @@
+/*
+ * This project is licensed under the MIT license. Module model-view-viewmodel is using ZK framework licensed under LGPL (see lgpl-3.0.txt).
+ *
+ * The MIT License
+ * Copyright © 2014-2022 Ilkka Seppälä
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+package com.iluwatar.viewhelper;
+
+public interface ViewHelper {
+ V prepare(M source);
+}
diff --git a/view-helper/src/test/java/com/iluwatar/viewhelper/AppTest.java b/view-helper/src/test/java/com/iluwatar/viewhelper/AppTest.java
new file mode 100644
index 000000000000..bc4a31cc43a8
--- /dev/null
+++ b/view-helper/src/test/java/com/iluwatar/viewhelper/AppTest.java
@@ -0,0 +1,39 @@
+/*
+ * This project is licensed under the MIT license. Module model-view-viewmodel is using ZK framework licensed under LGPL (see lgpl-3.0.txt).
+ *
+ * The MIT License
+ * Copyright © 2014-2022 Ilkka Seppälä
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+package com.iluwatar.viewhelper;
+
+import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
+
+import org.junit.jupiter.api.Test;
+
+/** Application test */
+class AppTest {
+
+ @Test
+ void shouldExecuteApplicationWithoutException() {
+ assertDoesNotThrow(() -> App.main(new String[] {}));
+ }
+}
diff --git a/view-helper/src/test/java/com/iluwatar/viewhelper/ProductViewHelperTest.java b/view-helper/src/test/java/com/iluwatar/viewhelper/ProductViewHelperTest.java
new file mode 100644
index 000000000000..49cc48556f47
--- /dev/null
+++ b/view-helper/src/test/java/com/iluwatar/viewhelper/ProductViewHelperTest.java
@@ -0,0 +1,60 @@
+/*
+ * This project is licensed under the MIT license. Module model-view-viewmodel is using ZK framework licensed under LGPL (see lgpl-3.0.txt).
+ *
+ * The MIT License
+ * Copyright © 2014-2022 Ilkka Seppälä
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+package com.iluwatar.viewhelper;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+import java.math.BigDecimal;
+import java.time.LocalDate;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+
+class ProductViewHelperTest {
+
+ private ProductViewHelper helper;
+
+ @BeforeEach
+ void setUp() {
+ helper = new ProductViewHelper();
+ }
+
+ @Test
+ void shouldFormatProductWithoutDiscount() {
+ var product = new Product("X", new BigDecimal("10.00"), LocalDate.of(2025, 1, 1), false);
+ ProductViewModel viewModel = helper.prepare(product);
+
+ assertEquals("X", viewModel.name());
+ assertEquals("$10.00", viewModel.price());
+ assertEquals("2025-01-01", viewModel.releasedDate());
+ }
+
+ @Test
+ void shouldFormatProductWithDiscount() {
+ var product = new Product("X", new BigDecimal("10.00"), LocalDate.of(2025, 1, 1), true);
+ ProductViewModel viewModel = helper.prepare(product);
+
+ assertEquals("X ON SALE", viewModel.name()); // locale follows JVM default
+ }
+}