From 48993c97187b14904ea90a94360f24a7ee28aee2 Mon Sep 17 00:00:00 2001 From: Md Moinul Hossain Date: Wed, 16 Jun 2021 17:31:52 +0600 Subject: [PATCH 1/6] BAEL-4994 code added for mvc and mvp architecture --- .../src/com/baeldung/mvc/MvcMainClass.java | 24 ++++++++++ mvc-mvp/src/com/baeldung/mvc/Product.java | 45 +++++++++++++++++++ .../com/baeldung/mvc/ProductController.java | 34 ++++++++++++++ mvc-mvp/src/com/baeldung/mvc/ProductView.java | 11 +++++ .../src/com/baeldung/mvp/MvpMainClass.java | 22 +++++++++ mvc-mvp/src/com/baeldung/mvp/Product.java | 32 +++++++++++++ .../com/baeldung/mvp/ProductController.java | 40 +++++++++++++++++ mvc-mvp/src/com/baeldung/mvp/ProductView.java | 11 +++++ 8 files changed, 219 insertions(+) create mode 100644 mvc-mvp/src/com/baeldung/mvc/MvcMainClass.java create mode 100644 mvc-mvp/src/com/baeldung/mvc/Product.java create mode 100644 mvc-mvp/src/com/baeldung/mvc/ProductController.java create mode 100644 mvc-mvp/src/com/baeldung/mvc/ProductView.java create mode 100644 mvc-mvp/src/com/baeldung/mvp/MvpMainClass.java create mode 100644 mvc-mvp/src/com/baeldung/mvp/Product.java create mode 100644 mvc-mvp/src/com/baeldung/mvp/ProductController.java create mode 100644 mvc-mvp/src/com/baeldung/mvp/ProductView.java diff --git a/mvc-mvp/src/com/baeldung/mvc/MvcMainClass.java b/mvc-mvp/src/com/baeldung/mvc/MvcMainClass.java new file mode 100644 index 0000000000..479c8dd591 --- /dev/null +++ b/mvc-mvp/src/com/baeldung/mvc/MvcMainClass.java @@ -0,0 +1,24 @@ +package com.baeldung.mvc; + +public class MvcMainClass { + + public static void main(String[] args) { + + Product model = retrieveProductFromDatabase(); + ProductView view = new ProductView(); + model.setProductView(view); + model.showProduct(); + + ProductController controller = new ProductController(model); + controller.setProductName("SmartPhone"); + model.showProduct(); + } + + private static Product retrieveProductFromDatabase() { + Product product = new Product(); + product.setProductName("Mobile"); + product.setProductDescription("New Brand"); + product.setProductPrice(1000.0); + return product; + } +} diff --git a/mvc-mvp/src/com/baeldung/mvc/Product.java b/mvc-mvp/src/com/baeldung/mvc/Product.java new file mode 100644 index 0000000000..2e05e26a3a --- /dev/null +++ b/mvc-mvp/src/com/baeldung/mvc/Product.java @@ -0,0 +1,45 @@ +package com.baeldung.mvc; + +public class Product { + private String productName; + private String productDescription; + private Double productPrice; + private ProductView productView; + + public String getProductName() { + return productName; + } + + public void setProductName(String productName) { + this.productName = productName; + } + + public String getProductDescription() { + return productDescription; + } + + public void setProductDescription(String productDescription) { + this.productDescription = productDescription; + } + + public Double getProductPrice() { + return productPrice; + } + + public void setProductPrice(Double productPrice) { + this.productPrice = productPrice; + } + + public ProductView getProductView() { + return productView; + } + + public void setProductView(ProductView productView) { + this.productView = productView; + } + + public void showProduct() { + productView.printProductDetails(productName, productDescription, productPrice); + } + +} diff --git a/mvc-mvp/src/com/baeldung/mvc/ProductController.java b/mvc-mvp/src/com/baeldung/mvc/ProductController.java new file mode 100644 index 0000000000..673b179e57 --- /dev/null +++ b/mvc-mvp/src/com/baeldung/mvc/ProductController.java @@ -0,0 +1,34 @@ +package com.baeldung.mvc; + +public class ProductController { + private final Product product; + + public ProductController(Product product) { + this.product = product; + } + + public String getProductName() { + return product.getProductName(); + } + + public void setProductName(String productName) { + product.setProductName(productName); + } + + public String getProductDescription() { + return product.getProductDescription(); + } + + public void setProductDescription(String productDescription) { + product.setProductDescription(productDescription); + } + + public Double getProductPrice() { + return product.getProductPrice(); + } + + public void setProductPrice(Double productPrice) { + product.setProductPrice(productPrice); + } + +} diff --git a/mvc-mvp/src/com/baeldung/mvc/ProductView.java b/mvc-mvp/src/com/baeldung/mvc/ProductView.java new file mode 100644 index 0000000000..9e1b2e5cb7 --- /dev/null +++ b/mvc-mvp/src/com/baeldung/mvc/ProductView.java @@ -0,0 +1,11 @@ +package com.baeldung.mvc; + +public class ProductView { + public void printProductDetails(String productName, String productDescription, Double productPrice) { + System.out.println("Product details:"); + System.out.println("product Name: " + productName); + System.out.println("product Description: " + productDescription); + System.out.println("product price: " + productPrice); + + } +} diff --git a/mvc-mvp/src/com/baeldung/mvp/MvpMainClass.java b/mvc-mvp/src/com/baeldung/mvp/MvpMainClass.java new file mode 100644 index 0000000000..f40cccca74 --- /dev/null +++ b/mvc-mvp/src/com/baeldung/mvp/MvpMainClass.java @@ -0,0 +1,22 @@ +package com.baeldung.mvp; + +public class MvpMainClass { + + public static void main(String[] args) { + + Product model = retrieveProductFromDatabase(); + ProductView view = new ProductView(); + ProductController controller = new ProductController(model, view); + controller.showProduct(); + controller.setProductName("SmartPhone"); + controller.showProduct(); + } + + private static Product retrieveProductFromDatabase() { + Product product = new Product(); + product.setProductName("Mobile"); + product.setProductDescription("New Brand"); + product.setProductPrice(1000.0); + return product; + } +} diff --git a/mvc-mvp/src/com/baeldung/mvp/Product.java b/mvc-mvp/src/com/baeldung/mvp/Product.java new file mode 100644 index 0000000000..902aa7100c --- /dev/null +++ b/mvc-mvp/src/com/baeldung/mvp/Product.java @@ -0,0 +1,32 @@ +package com.baeldung.mvp; + +public class Product { + private String productName; + private String productDescription; + private Double productPrice; + + public String getProductName() { + return productName; + } + + public void setProductName(String productName) { + this.productName = productName; + } + + public String getProductDescription() { + return productDescription; + } + + public void setProductDescription(String productDescription) { + this.productDescription = productDescription; + } + + public Double getProductPrice() { + return productPrice; + } + + public void setProductPrice(Double productPrice) { + this.productPrice = productPrice; + } + +} diff --git a/mvc-mvp/src/com/baeldung/mvp/ProductController.java b/mvc-mvp/src/com/baeldung/mvp/ProductController.java new file mode 100644 index 0000000000..5cf32b3f0b --- /dev/null +++ b/mvc-mvp/src/com/baeldung/mvp/ProductController.java @@ -0,0 +1,40 @@ +package com.baeldung.mvp; + +public class ProductController { + private final Product product; + private final ProductView productView; + + public ProductController(Product product, ProductView productView) { + this.product = product; + this.productView = productView; + } + + public String getProductName() { + return product.getProductName(); + } + + public void setProductName(String productName) { + product.setProductName(productName); + } + + public String getProductDescription() { + return product.getProductDescription(); + } + + public void setProductDescription(String productDescription) { + product.setProductDescription(productDescription); + } + + public Double getProductPrice() { + return product.getProductPrice(); + } + + public void setProductPrice(Double productPrice) { + product.setProductPrice(productPrice); + } + + public void showProduct() { + productView.printProductDetails(product.getProductName(), product.getProductDescription(), product.getProductPrice()); + } + +} diff --git a/mvc-mvp/src/com/baeldung/mvp/ProductView.java b/mvc-mvp/src/com/baeldung/mvp/ProductView.java new file mode 100644 index 0000000000..edb3dddddc --- /dev/null +++ b/mvc-mvp/src/com/baeldung/mvp/ProductView.java @@ -0,0 +1,11 @@ +package com.baeldung.mvp; + +public class ProductView { + public void printProductDetails(String productName, String productDescription, Double productPrice) { + System.out.println("Product details:"); + System.out.println("product Name: " + productName); + System.out.println("product Description: " + productDescription); + System.out.println("product price: " + productPrice); + + } +} From be2d8a668fd18885a26eaf0e9ffef4bfaaa0e57c Mon Sep 17 00:00:00 2001 From: Md Moinul Hossain Date: Wed, 16 Jun 2021 18:09:58 +0600 Subject: [PATCH 2/6] BAEL-4994 Class name changed in mvp --- mvc-mvp/src/com/baeldung/mvp/MvpMainClass.java | 8 ++++---- .../mvp/{ProductController.java => ProductPresenter.java} | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) rename mvc-mvp/src/com/baeldung/mvp/{ProductController.java => ProductPresenter.java} (90%) diff --git a/mvc-mvp/src/com/baeldung/mvp/MvpMainClass.java b/mvc-mvp/src/com/baeldung/mvp/MvpMainClass.java index f40cccca74..98b616219d 100644 --- a/mvc-mvp/src/com/baeldung/mvp/MvpMainClass.java +++ b/mvc-mvp/src/com/baeldung/mvp/MvpMainClass.java @@ -6,10 +6,10 @@ public class MvpMainClass { Product model = retrieveProductFromDatabase(); ProductView view = new ProductView(); - ProductController controller = new ProductController(model, view); - controller.showProduct(); - controller.setProductName("SmartPhone"); - controller.showProduct(); + ProductPresenter presenter = new ProductPresenter(model, view); + presenter.showProduct(); + presenter.setProductName("SmartPhone"); + presenter.showProduct(); } private static Product retrieveProductFromDatabase() { diff --git a/mvc-mvp/src/com/baeldung/mvp/ProductController.java b/mvc-mvp/src/com/baeldung/mvp/ProductPresenter.java similarity index 90% rename from mvc-mvp/src/com/baeldung/mvp/ProductController.java rename to mvc-mvp/src/com/baeldung/mvp/ProductPresenter.java index 5cf32b3f0b..b9549026a9 100644 --- a/mvc-mvp/src/com/baeldung/mvp/ProductController.java +++ b/mvc-mvp/src/com/baeldung/mvp/ProductPresenter.java @@ -1,10 +1,10 @@ package com.baeldung.mvp; -public class ProductController { +public class ProductPresenter { private final Product product; private final ProductView productView; - public ProductController(Product product, ProductView productView) { + public ProductPresenter(Product product, ProductView productView) { this.product = product; this.productView = productView; } From d478ffc07916f100f56b0bf996cc6bbaa17ea95a Mon Sep 17 00:00:00 2001 From: Md Moinul Hossain Date: Fri, 25 Jun 2021 00:17:10 +0600 Subject: [PATCH 3/6] BAEL-4994 moved to parrtern module --- .../baeldung/mvc_mvp/mvc/MvcMainClass.java | 24 ++++++++++ .../com/baeldung/mvc_mvp/mvc/Product.java | 45 +++++++++++++++++++ .../mvc_mvp/mvc/ProductController.java | 34 ++++++++++++++ .../com/baeldung/mvc_mvp/mvc/ProductView.java | 16 +++++++ .../baeldung/mvc_mvp/mvp/MvpMainClass.java | 22 +++++++++ .../com/baeldung/mvc_mvp/mvp/Product.java | 32 +++++++++++++ .../mvc_mvp/mvp/ProductPresenter.java | 40 +++++++++++++++++ .../com/baeldung/mvc_mvp/mvp/ProductView.java | 16 +++++++ 8 files changed, 229 insertions(+) create mode 100644 patterns/design-patterns-architectural/src/main/java/com/baeldung/mvc_mvp/mvc/MvcMainClass.java create mode 100644 patterns/design-patterns-architectural/src/main/java/com/baeldung/mvc_mvp/mvc/Product.java create mode 100644 patterns/design-patterns-architectural/src/main/java/com/baeldung/mvc_mvp/mvc/ProductController.java create mode 100644 patterns/design-patterns-architectural/src/main/java/com/baeldung/mvc_mvp/mvc/ProductView.java create mode 100644 patterns/design-patterns-architectural/src/main/java/com/baeldung/mvc_mvp/mvp/MvpMainClass.java create mode 100644 patterns/design-patterns-architectural/src/main/java/com/baeldung/mvc_mvp/mvp/Product.java create mode 100644 patterns/design-patterns-architectural/src/main/java/com/baeldung/mvc_mvp/mvp/ProductPresenter.java create mode 100644 patterns/design-patterns-architectural/src/main/java/com/baeldung/mvc_mvp/mvp/ProductView.java diff --git a/patterns/design-patterns-architectural/src/main/java/com/baeldung/mvc_mvp/mvc/MvcMainClass.java b/patterns/design-patterns-architectural/src/main/java/com/baeldung/mvc_mvp/mvc/MvcMainClass.java new file mode 100644 index 0000000000..e89d7239eb --- /dev/null +++ b/patterns/design-patterns-architectural/src/main/java/com/baeldung/mvc_mvp/mvc/MvcMainClass.java @@ -0,0 +1,24 @@ +package com.baeldung.mvc_mvp.mvc; + +public class MvcMainClass { + + public static void main(String[] args) { + + Product model = retrieveProductFromDatabase(); + ProductView view = new ProductView(); + model.setProductView(view); + model.showProduct(); + + ProductController controller = new ProductController(model); + controller.setProductName("SmartPhone"); + model.showProduct(); + } + + private static Product retrieveProductFromDatabase() { + Product product = new Product(); + product.setProductName("Mobile"); + product.setProductDescription("New Brand"); + product.setProductPrice(1000.0); + return product; + } +} diff --git a/patterns/design-patterns-architectural/src/main/java/com/baeldung/mvc_mvp/mvc/Product.java b/patterns/design-patterns-architectural/src/main/java/com/baeldung/mvc_mvp/mvc/Product.java new file mode 100644 index 0000000000..6e04b223e4 --- /dev/null +++ b/patterns/design-patterns-architectural/src/main/java/com/baeldung/mvc_mvp/mvc/Product.java @@ -0,0 +1,45 @@ +package com.baeldung.mvc_mvp.mvc; + +public class Product { + private String productName; + private String productDescription; + private Double productPrice; + private ProductView productView; + + public String getProductName() { + return productName; + } + + public void setProductName(String productName) { + this.productName = productName; + } + + public String getProductDescription() { + return productDescription; + } + + public void setProductDescription(String productDescription) { + this.productDescription = productDescription; + } + + public Double getProductPrice() { + return productPrice; + } + + public void setProductPrice(Double productPrice) { + this.productPrice = productPrice; + } + + public ProductView getProductView() { + return productView; + } + + public void setProductView(ProductView productView) { + this.productView = productView; + } + + public void showProduct() { + productView.printProductDetails(productName, productDescription, productPrice); + } + +} diff --git a/patterns/design-patterns-architectural/src/main/java/com/baeldung/mvc_mvp/mvc/ProductController.java b/patterns/design-patterns-architectural/src/main/java/com/baeldung/mvc_mvp/mvc/ProductController.java new file mode 100644 index 0000000000..922d4d703b --- /dev/null +++ b/patterns/design-patterns-architectural/src/main/java/com/baeldung/mvc_mvp/mvc/ProductController.java @@ -0,0 +1,34 @@ +package com.baeldung.mvc_mvp.mvc; + +public class ProductController { + private final Product product; + + public ProductController(Product product) { + this.product = product; + } + + public String getProductName() { + return product.getProductName(); + } + + public void setProductName(String productName) { + product.setProductName(productName); + } + + public String getProductDescription() { + return product.getProductDescription(); + } + + public void setProductDescription(String productDescription) { + product.setProductDescription(productDescription); + } + + public Double getProductPrice() { + return product.getProductPrice(); + } + + public void setProductPrice(Double productPrice) { + product.setProductPrice(productPrice); + } + +} diff --git a/patterns/design-patterns-architectural/src/main/java/com/baeldung/mvc_mvp/mvc/ProductView.java b/patterns/design-patterns-architectural/src/main/java/com/baeldung/mvc_mvp/mvc/ProductView.java new file mode 100644 index 0000000000..e8031b6398 --- /dev/null +++ b/patterns/design-patterns-architectural/src/main/java/com/baeldung/mvc_mvp/mvc/ProductView.java @@ -0,0 +1,16 @@ +package com.baeldung.mvc_mvp.mvc; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class ProductView { + private static Logger log = LoggerFactory.getLogger(ProductView.class); + + public void printProductDetails(String productName, String productDescription, Double productPrice) { + log.info("Product details:"); + log.info("product Name: " + productName); + log.info("product Description: " + productDescription); + log.info("product price: " + productPrice); + + } +} diff --git a/patterns/design-patterns-architectural/src/main/java/com/baeldung/mvc_mvp/mvp/MvpMainClass.java b/patterns/design-patterns-architectural/src/main/java/com/baeldung/mvc_mvp/mvp/MvpMainClass.java new file mode 100644 index 0000000000..b501ac5ec5 --- /dev/null +++ b/patterns/design-patterns-architectural/src/main/java/com/baeldung/mvc_mvp/mvp/MvpMainClass.java @@ -0,0 +1,22 @@ +package com.baeldung.mvc_mvp.mvp; + +public class MvpMainClass { + + public static void main(String[] args) { + + Product model = retrieveProductFromDatabase(); + ProductView view = new ProductView(); + ProductPresenter presenter = new ProductPresenter(model, view); + presenter.showProduct(); + presenter.setProductName("SmartPhone"); + presenter.showProduct(); + } + + private static Product retrieveProductFromDatabase() { + Product product = new Product(); + product.setProductName("Mobile"); + product.setProductDescription("New Brand"); + product.setProductPrice(1000.0); + return product; + } +} diff --git a/patterns/design-patterns-architectural/src/main/java/com/baeldung/mvc_mvp/mvp/Product.java b/patterns/design-patterns-architectural/src/main/java/com/baeldung/mvc_mvp/mvp/Product.java new file mode 100644 index 0000000000..700ee15ef6 --- /dev/null +++ b/patterns/design-patterns-architectural/src/main/java/com/baeldung/mvc_mvp/mvp/Product.java @@ -0,0 +1,32 @@ +package com.baeldung.mvc_mvp.mvp; + +public class Product { + private String productName; + private String productDescription; + private Double productPrice; + + public String getProductName() { + return productName; + } + + public void setProductName(String productName) { + this.productName = productName; + } + + public String getProductDescription() { + return productDescription; + } + + public void setProductDescription(String productDescription) { + this.productDescription = productDescription; + } + + public Double getProductPrice() { + return productPrice; + } + + public void setProductPrice(Double productPrice) { + this.productPrice = productPrice; + } + +} diff --git a/patterns/design-patterns-architectural/src/main/java/com/baeldung/mvc_mvp/mvp/ProductPresenter.java b/patterns/design-patterns-architectural/src/main/java/com/baeldung/mvc_mvp/mvp/ProductPresenter.java new file mode 100644 index 0000000000..984766b299 --- /dev/null +++ b/patterns/design-patterns-architectural/src/main/java/com/baeldung/mvc_mvp/mvp/ProductPresenter.java @@ -0,0 +1,40 @@ +package com.baeldung.mvc_mvp.mvp; + +public class ProductPresenter { + private final Product product; + private final ProductView productView; + + public ProductPresenter(Product product, ProductView productView) { + this.product = product; + this.productView = productView; + } + + public String getProductName() { + return product.getProductName(); + } + + public void setProductName(String productName) { + product.setProductName(productName); + } + + public String getProductDescription() { + return product.getProductDescription(); + } + + public void setProductDescription(String productDescription) { + product.setProductDescription(productDescription); + } + + public Double getProductPrice() { + return product.getProductPrice(); + } + + public void setProductPrice(Double productPrice) { + product.setProductPrice(productPrice); + } + + public void showProduct() { + productView.printProductDetails(product.getProductName(), product.getProductDescription(), product.getProductPrice()); + } + +} diff --git a/patterns/design-patterns-architectural/src/main/java/com/baeldung/mvc_mvp/mvp/ProductView.java b/patterns/design-patterns-architectural/src/main/java/com/baeldung/mvc_mvp/mvp/ProductView.java new file mode 100644 index 0000000000..7ee931612a --- /dev/null +++ b/patterns/design-patterns-architectural/src/main/java/com/baeldung/mvc_mvp/mvp/ProductView.java @@ -0,0 +1,16 @@ +package com.baeldung.mvc_mvp.mvp; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class ProductView { + private static Logger log = LoggerFactory.getLogger(ProductView.class); + + public void printProductDetails(String productName, String productDescription, Double productPrice) { + log.info("Product details:"); + log.info("product Name: " + productName); + log.info("product Description: " + productDescription); + log.info("product price: " + productPrice); + + } +} From ff8372aa5573316f93636534f7e9a6f4e157f847 Mon Sep 17 00:00:00 2001 From: Md Moinul Hossain Date: Fri, 25 Jun 2021 00:25:33 +0600 Subject: [PATCH 4/6] Extra white space removed --- .../src/main/java/com/baeldung/mvc_mvp/mvc/ProductView.java | 1 - .../src/main/java/com/baeldung/mvc_mvp/mvp/ProductView.java | 1 - 2 files changed, 2 deletions(-) diff --git a/patterns/design-patterns-architectural/src/main/java/com/baeldung/mvc_mvp/mvc/ProductView.java b/patterns/design-patterns-architectural/src/main/java/com/baeldung/mvc_mvp/mvc/ProductView.java index e8031b6398..19ef7d3629 100644 --- a/patterns/design-patterns-architectural/src/main/java/com/baeldung/mvc_mvp/mvc/ProductView.java +++ b/patterns/design-patterns-architectural/src/main/java/com/baeldung/mvc_mvp/mvc/ProductView.java @@ -11,6 +11,5 @@ public class ProductView { log.info("product Name: " + productName); log.info("product Description: " + productDescription); log.info("product price: " + productPrice); - } } diff --git a/patterns/design-patterns-architectural/src/main/java/com/baeldung/mvc_mvp/mvp/ProductView.java b/patterns/design-patterns-architectural/src/main/java/com/baeldung/mvc_mvp/mvp/ProductView.java index 7ee931612a..4555977439 100644 --- a/patterns/design-patterns-architectural/src/main/java/com/baeldung/mvc_mvp/mvp/ProductView.java +++ b/patterns/design-patterns-architectural/src/main/java/com/baeldung/mvc_mvp/mvp/ProductView.java @@ -11,6 +11,5 @@ public class ProductView { log.info("product Name: " + productName); log.info("product Description: " + productDescription); log.info("product price: " + productPrice); - } } From bdec91c26837f82fb5f2d41d53b3712ac3f71326 Mon Sep 17 00:00:00 2001 From: Md Moinul Hossain Date: Tue, 20 Jul 2021 11:21:17 +0600 Subject: [PATCH 5/6] BAEL-4994 names updated --- .../baeldung/mvc_mvp/mvc/MvcMainClass.java | 10 ++--- .../com/baeldung/mvc_mvp/mvc/Product.java | 42 +++++++++---------- .../mvc_mvp/mvc/ProductController.java | 24 +++++------ .../com/baeldung/mvc_mvp/mvc/ProductView.java | 8 ++-- .../baeldung/mvc_mvp/mvp/MvpMainClass.java | 8 ++-- .../com/baeldung/mvc_mvp/mvp/Product.java | 30 ++++++------- .../mvc_mvp/mvp/ProductPresenter.java | 30 ++++++------- .../com/baeldung/mvc_mvp/mvp/ProductView.java | 8 ++-- 8 files changed, 80 insertions(+), 80 deletions(-) diff --git a/patterns/design-patterns-architectural/src/main/java/com/baeldung/mvc_mvp/mvc/MvcMainClass.java b/patterns/design-patterns-architectural/src/main/java/com/baeldung/mvc_mvp/mvc/MvcMainClass.java index e89d7239eb..9ccd4ee74c 100644 --- a/patterns/design-patterns-architectural/src/main/java/com/baeldung/mvc_mvp/mvc/MvcMainClass.java +++ b/patterns/design-patterns-architectural/src/main/java/com/baeldung/mvc_mvp/mvc/MvcMainClass.java @@ -6,19 +6,19 @@ public class MvcMainClass { Product model = retrieveProductFromDatabase(); ProductView view = new ProductView(); - model.setProductView(view); + model.setView(view); model.showProduct(); ProductController controller = new ProductController(model); - controller.setProductName("SmartPhone"); + controller.setName("SmartPhone"); model.showProduct(); } private static Product retrieveProductFromDatabase() { Product product = new Product(); - product.setProductName("Mobile"); - product.setProductDescription("New Brand"); - product.setProductPrice(1000.0); + product.setName("Mobile"); + product.setDescription("New Brand"); + product.setPrice(1000.0); return product; } } diff --git a/patterns/design-patterns-architectural/src/main/java/com/baeldung/mvc_mvp/mvc/Product.java b/patterns/design-patterns-architectural/src/main/java/com/baeldung/mvc_mvp/mvc/Product.java index 6e04b223e4..5c44d4475a 100644 --- a/patterns/design-patterns-architectural/src/main/java/com/baeldung/mvc_mvp/mvc/Product.java +++ b/patterns/design-patterns-architectural/src/main/java/com/baeldung/mvc_mvp/mvc/Product.java @@ -1,45 +1,45 @@ package com.baeldung.mvc_mvp.mvc; public class Product { - private String productName; - private String productDescription; - private Double productPrice; - private ProductView productView; + private String name; + private String description; + private Double price; + private ProductView view; - public String getProductName() { - return productName; + public String getName() { + return name; } - public void setProductName(String productName) { - this.productName = productName; + public void setName(String name) { + this.name = name; } - public String getProductDescription() { - return productDescription; + public String getDescription() { + return description; } - public void setProductDescription(String productDescription) { - this.productDescription = productDescription; + public void setDescription(String description) { + this.description = description; } - public Double getProductPrice() { - return productPrice; + public Double getPrice() { + return price; } - public void setProductPrice(Double productPrice) { - this.productPrice = productPrice; + public void setPrice(Double price) { + this.price = price; } - public ProductView getProductView() { - return productView; + public ProductView getView() { + return view; } - public void setProductView(ProductView productView) { - this.productView = productView; + public void setView(ProductView view) { + this.view = view; } public void showProduct() { - productView.printProductDetails(productName, productDescription, productPrice); + view.printProductDetails(name, description, price); } } diff --git a/patterns/design-patterns-architectural/src/main/java/com/baeldung/mvc_mvp/mvc/ProductController.java b/patterns/design-patterns-architectural/src/main/java/com/baeldung/mvc_mvp/mvc/ProductController.java index 922d4d703b..62cdb76f23 100644 --- a/patterns/design-patterns-architectural/src/main/java/com/baeldung/mvc_mvp/mvc/ProductController.java +++ b/patterns/design-patterns-architectural/src/main/java/com/baeldung/mvc_mvp/mvc/ProductController.java @@ -7,28 +7,28 @@ public class ProductController { this.product = product; } - public String getProductName() { - return product.getProductName(); + public String getName() { + return product.getName(); } - public void setProductName(String productName) { - product.setProductName(productName); + public void setName(String name) { + product.setName(name); } - public String getProductDescription() { - return product.getProductDescription(); + public String getDescription() { + return product.getDescription(); } - public void setProductDescription(String productDescription) { - product.setProductDescription(productDescription); + public void setDescription(String description) { + product.setDescription(description); } - public Double getProductPrice() { - return product.getProductPrice(); + public Double getPrice() { + return product.getPrice(); } - public void setProductPrice(Double productPrice) { - product.setProductPrice(productPrice); + public void setPrice(Double price) { + product.setPrice(price); } } diff --git a/patterns/design-patterns-architectural/src/main/java/com/baeldung/mvc_mvp/mvc/ProductView.java b/patterns/design-patterns-architectural/src/main/java/com/baeldung/mvc_mvp/mvc/ProductView.java index 19ef7d3629..43f45b6df7 100644 --- a/patterns/design-patterns-architectural/src/main/java/com/baeldung/mvc_mvp/mvc/ProductView.java +++ b/patterns/design-patterns-architectural/src/main/java/com/baeldung/mvc_mvp/mvc/ProductView.java @@ -6,10 +6,10 @@ import org.slf4j.LoggerFactory; public class ProductView { private static Logger log = LoggerFactory.getLogger(ProductView.class); - public void printProductDetails(String productName, String productDescription, Double productPrice) { + public void printProductDetails(String name, String description, Double price) { log.info("Product details:"); - log.info("product Name: " + productName); - log.info("product Description: " + productDescription); - log.info("product price: " + productPrice); + log.info("product Name: " + name); + log.info("product Description: " + description); + log.info("product price: " + price); } } diff --git a/patterns/design-patterns-architectural/src/main/java/com/baeldung/mvc_mvp/mvp/MvpMainClass.java b/patterns/design-patterns-architectural/src/main/java/com/baeldung/mvc_mvp/mvp/MvpMainClass.java index b501ac5ec5..7d12a0142c 100644 --- a/patterns/design-patterns-architectural/src/main/java/com/baeldung/mvc_mvp/mvp/MvpMainClass.java +++ b/patterns/design-patterns-architectural/src/main/java/com/baeldung/mvc_mvp/mvp/MvpMainClass.java @@ -8,15 +8,15 @@ public class MvpMainClass { ProductView view = new ProductView(); ProductPresenter presenter = new ProductPresenter(model, view); presenter.showProduct(); - presenter.setProductName("SmartPhone"); + presenter.setName("SmartPhone"); presenter.showProduct(); } private static Product retrieveProductFromDatabase() { Product product = new Product(); - product.setProductName("Mobile"); - product.setProductDescription("New Brand"); - product.setProductPrice(1000.0); + product.setName("Mobile"); + product.setDescription("New Brand"); + product.setPrice(1000.0); return product; } } diff --git a/patterns/design-patterns-architectural/src/main/java/com/baeldung/mvc_mvp/mvp/Product.java b/patterns/design-patterns-architectural/src/main/java/com/baeldung/mvc_mvp/mvp/Product.java index 700ee15ef6..315e6e69b6 100644 --- a/patterns/design-patterns-architectural/src/main/java/com/baeldung/mvc_mvp/mvp/Product.java +++ b/patterns/design-patterns-architectural/src/main/java/com/baeldung/mvc_mvp/mvp/Product.java @@ -1,32 +1,32 @@ package com.baeldung.mvc_mvp.mvp; public class Product { - private String productName; - private String productDescription; - private Double productPrice; + private String name; + private String description; + private Double price; - public String getProductName() { - return productName; + public String getName() { + return name; } - public void setProductName(String productName) { - this.productName = productName; + public void setName(String name) { + this.name = name; } - public String getProductDescription() { - return productDescription; + public String getDescription() { + return description; } - public void setProductDescription(String productDescription) { - this.productDescription = productDescription; + public void setDescription(String description) { + this.description = description; } - public Double getProductPrice() { - return productPrice; + public Double getPrice() { + return price; } - public void setProductPrice(Double productPrice) { - this.productPrice = productPrice; + public void setPrice(Double price) { + this.price = price; } } diff --git a/patterns/design-patterns-architectural/src/main/java/com/baeldung/mvc_mvp/mvp/ProductPresenter.java b/patterns/design-patterns-architectural/src/main/java/com/baeldung/mvc_mvp/mvp/ProductPresenter.java index 984766b299..2b87bdbbb5 100644 --- a/patterns/design-patterns-architectural/src/main/java/com/baeldung/mvc_mvp/mvp/ProductPresenter.java +++ b/patterns/design-patterns-architectural/src/main/java/com/baeldung/mvc_mvp/mvp/ProductPresenter.java @@ -2,39 +2,39 @@ package com.baeldung.mvc_mvp.mvp; public class ProductPresenter { private final Product product; - private final ProductView productView; + private final ProductView view; - public ProductPresenter(Product product, ProductView productView) { + public ProductPresenter(Product product, ProductView view) { this.product = product; - this.productView = productView; + this.view = view; } - public String getProductName() { - return product.getProductName(); + public String getName() { + return product.getName(); } - public void setProductName(String productName) { - product.setProductName(productName); + public void setName(String name) { + product.setName(name); } - public String getProductDescription() { - return product.getProductDescription(); + public String getDescription() { + return product.getDescription(); } - public void setProductDescription(String productDescription) { - product.setProductDescription(productDescription); + public void setDescription(String description) { + product.setDescription(description); } public Double getProductPrice() { - return product.getProductPrice(); + return product.getPrice(); } - public void setProductPrice(Double productPrice) { - product.setProductPrice(productPrice); + public void setPrice(Double price) { + product.setPrice(price); } public void showProduct() { - productView.printProductDetails(product.getProductName(), product.getProductDescription(), product.getProductPrice()); + view.printProductDetails(product.getName(), product.getDescription(), product.getPrice()); } } diff --git a/patterns/design-patterns-architectural/src/main/java/com/baeldung/mvc_mvp/mvp/ProductView.java b/patterns/design-patterns-architectural/src/main/java/com/baeldung/mvc_mvp/mvp/ProductView.java index 4555977439..27ccc6743d 100644 --- a/patterns/design-patterns-architectural/src/main/java/com/baeldung/mvc_mvp/mvp/ProductView.java +++ b/patterns/design-patterns-architectural/src/main/java/com/baeldung/mvc_mvp/mvp/ProductView.java @@ -6,10 +6,10 @@ import org.slf4j.LoggerFactory; public class ProductView { private static Logger log = LoggerFactory.getLogger(ProductView.class); - public void printProductDetails(String productName, String productDescription, Double productPrice) { + public void printProductDetails(String name, String description, Double price) { log.info("Product details:"); - log.info("product Name: " + productName); - log.info("product Description: " + productDescription); - log.info("product price: " + productPrice); + log.info("product Name: " + name); + log.info("product Description: " + description); + log.info("product price: " + price); } } From c5bada9f8b570b570c897767de3e9d54788dd301 Mon Sep 17 00:00:00 2001 From: Md Moinul Hossain Date: Wed, 28 Jul 2021 23:40:25 +0600 Subject: [PATCH 6/6] BAEL-4994 extra mvc-mvp module removed --- .../src/com/baeldung/mvc/MvcMainClass.java | 24 ---------- mvc-mvp/src/com/baeldung/mvc/Product.java | 45 ------------------- .../com/baeldung/mvc/ProductController.java | 34 -------------- mvc-mvp/src/com/baeldung/mvc/ProductView.java | 11 ----- .../src/com/baeldung/mvp/MvpMainClass.java | 22 --------- mvc-mvp/src/com/baeldung/mvp/Product.java | 32 ------------- .../com/baeldung/mvp/ProductPresenter.java | 40 ----------------- mvc-mvp/src/com/baeldung/mvp/ProductView.java | 11 ----- 8 files changed, 219 deletions(-) delete mode 100644 mvc-mvp/src/com/baeldung/mvc/MvcMainClass.java delete mode 100644 mvc-mvp/src/com/baeldung/mvc/Product.java delete mode 100644 mvc-mvp/src/com/baeldung/mvc/ProductController.java delete mode 100644 mvc-mvp/src/com/baeldung/mvc/ProductView.java delete mode 100644 mvc-mvp/src/com/baeldung/mvp/MvpMainClass.java delete mode 100644 mvc-mvp/src/com/baeldung/mvp/Product.java delete mode 100644 mvc-mvp/src/com/baeldung/mvp/ProductPresenter.java delete mode 100644 mvc-mvp/src/com/baeldung/mvp/ProductView.java diff --git a/mvc-mvp/src/com/baeldung/mvc/MvcMainClass.java b/mvc-mvp/src/com/baeldung/mvc/MvcMainClass.java deleted file mode 100644 index 479c8dd591..0000000000 --- a/mvc-mvp/src/com/baeldung/mvc/MvcMainClass.java +++ /dev/null @@ -1,24 +0,0 @@ -package com.baeldung.mvc; - -public class MvcMainClass { - - public static void main(String[] args) { - - Product model = retrieveProductFromDatabase(); - ProductView view = new ProductView(); - model.setProductView(view); - model.showProduct(); - - ProductController controller = new ProductController(model); - controller.setProductName("SmartPhone"); - model.showProduct(); - } - - private static Product retrieveProductFromDatabase() { - Product product = new Product(); - product.setProductName("Mobile"); - product.setProductDescription("New Brand"); - product.setProductPrice(1000.0); - return product; - } -} diff --git a/mvc-mvp/src/com/baeldung/mvc/Product.java b/mvc-mvp/src/com/baeldung/mvc/Product.java deleted file mode 100644 index 2e05e26a3a..0000000000 --- a/mvc-mvp/src/com/baeldung/mvc/Product.java +++ /dev/null @@ -1,45 +0,0 @@ -package com.baeldung.mvc; - -public class Product { - private String productName; - private String productDescription; - private Double productPrice; - private ProductView productView; - - public String getProductName() { - return productName; - } - - public void setProductName(String productName) { - this.productName = productName; - } - - public String getProductDescription() { - return productDescription; - } - - public void setProductDescription(String productDescription) { - this.productDescription = productDescription; - } - - public Double getProductPrice() { - return productPrice; - } - - public void setProductPrice(Double productPrice) { - this.productPrice = productPrice; - } - - public ProductView getProductView() { - return productView; - } - - public void setProductView(ProductView productView) { - this.productView = productView; - } - - public void showProduct() { - productView.printProductDetails(productName, productDescription, productPrice); - } - -} diff --git a/mvc-mvp/src/com/baeldung/mvc/ProductController.java b/mvc-mvp/src/com/baeldung/mvc/ProductController.java deleted file mode 100644 index 673b179e57..0000000000 --- a/mvc-mvp/src/com/baeldung/mvc/ProductController.java +++ /dev/null @@ -1,34 +0,0 @@ -package com.baeldung.mvc; - -public class ProductController { - private final Product product; - - public ProductController(Product product) { - this.product = product; - } - - public String getProductName() { - return product.getProductName(); - } - - public void setProductName(String productName) { - product.setProductName(productName); - } - - public String getProductDescription() { - return product.getProductDescription(); - } - - public void setProductDescription(String productDescription) { - product.setProductDescription(productDescription); - } - - public Double getProductPrice() { - return product.getProductPrice(); - } - - public void setProductPrice(Double productPrice) { - product.setProductPrice(productPrice); - } - -} diff --git a/mvc-mvp/src/com/baeldung/mvc/ProductView.java b/mvc-mvp/src/com/baeldung/mvc/ProductView.java deleted file mode 100644 index 9e1b2e5cb7..0000000000 --- a/mvc-mvp/src/com/baeldung/mvc/ProductView.java +++ /dev/null @@ -1,11 +0,0 @@ -package com.baeldung.mvc; - -public class ProductView { - public void printProductDetails(String productName, String productDescription, Double productPrice) { - System.out.println("Product details:"); - System.out.println("product Name: " + productName); - System.out.println("product Description: " + productDescription); - System.out.println("product price: " + productPrice); - - } -} diff --git a/mvc-mvp/src/com/baeldung/mvp/MvpMainClass.java b/mvc-mvp/src/com/baeldung/mvp/MvpMainClass.java deleted file mode 100644 index 98b616219d..0000000000 --- a/mvc-mvp/src/com/baeldung/mvp/MvpMainClass.java +++ /dev/null @@ -1,22 +0,0 @@ -package com.baeldung.mvp; - -public class MvpMainClass { - - public static void main(String[] args) { - - Product model = retrieveProductFromDatabase(); - ProductView view = new ProductView(); - ProductPresenter presenter = new ProductPresenter(model, view); - presenter.showProduct(); - presenter.setProductName("SmartPhone"); - presenter.showProduct(); - } - - private static Product retrieveProductFromDatabase() { - Product product = new Product(); - product.setProductName("Mobile"); - product.setProductDescription("New Brand"); - product.setProductPrice(1000.0); - return product; - } -} diff --git a/mvc-mvp/src/com/baeldung/mvp/Product.java b/mvc-mvp/src/com/baeldung/mvp/Product.java deleted file mode 100644 index 902aa7100c..0000000000 --- a/mvc-mvp/src/com/baeldung/mvp/Product.java +++ /dev/null @@ -1,32 +0,0 @@ -package com.baeldung.mvp; - -public class Product { - private String productName; - private String productDescription; - private Double productPrice; - - public String getProductName() { - return productName; - } - - public void setProductName(String productName) { - this.productName = productName; - } - - public String getProductDescription() { - return productDescription; - } - - public void setProductDescription(String productDescription) { - this.productDescription = productDescription; - } - - public Double getProductPrice() { - return productPrice; - } - - public void setProductPrice(Double productPrice) { - this.productPrice = productPrice; - } - -} diff --git a/mvc-mvp/src/com/baeldung/mvp/ProductPresenter.java b/mvc-mvp/src/com/baeldung/mvp/ProductPresenter.java deleted file mode 100644 index b9549026a9..0000000000 --- a/mvc-mvp/src/com/baeldung/mvp/ProductPresenter.java +++ /dev/null @@ -1,40 +0,0 @@ -package com.baeldung.mvp; - -public class ProductPresenter { - private final Product product; - private final ProductView productView; - - public ProductPresenter(Product product, ProductView productView) { - this.product = product; - this.productView = productView; - } - - public String getProductName() { - return product.getProductName(); - } - - public void setProductName(String productName) { - product.setProductName(productName); - } - - public String getProductDescription() { - return product.getProductDescription(); - } - - public void setProductDescription(String productDescription) { - product.setProductDescription(productDescription); - } - - public Double getProductPrice() { - return product.getProductPrice(); - } - - public void setProductPrice(Double productPrice) { - product.setProductPrice(productPrice); - } - - public void showProduct() { - productView.printProductDetails(product.getProductName(), product.getProductDescription(), product.getProductPrice()); - } - -} diff --git a/mvc-mvp/src/com/baeldung/mvp/ProductView.java b/mvc-mvp/src/com/baeldung/mvp/ProductView.java deleted file mode 100644 index edb3dddddc..0000000000 --- a/mvc-mvp/src/com/baeldung/mvp/ProductView.java +++ /dev/null @@ -1,11 +0,0 @@ -package com.baeldung.mvp; - -public class ProductView { - public void printProductDetails(String productName, String productDescription, Double productPrice) { - System.out.println("Product details:"); - System.out.println("product Name: " + productName); - System.out.println("product Description: " + productDescription); - System.out.println("product price: " + productPrice); - - } -}