Facade Pattern in Java
facade
1
Java
215
Pattern
11
Male avatar

loveprogramming viết ngày 03/05/2021

https://grokonez.com/design-pattern/facade-pattern-java

Facade Pattern in Java

Facade Pattern is a Structural Pattern in which, a set of interfaces is gathered into only one interface that Client can work easily and simply. Facade Pattern helps us to wrap complexities of components inside and lose coupling between Client and subSystems.

I. OVERVIEW

Facade Pattern defines a higher interface/object - Facade - that wraps some lower interfaces/objects. Whenever Client wants to make a chain of complex actions which require many methods and interaction, it just call one simple Facade method, all operation can be done inside that method.
facade-pattern-overview
You can see that Facade object contains other interfaces/objects (A, B, C) and manages their operation by doWork() method.

II. PRACTICE

1. Project Overview
Assume that we have some operations such as: register, consultation, healthcare that a Customer will be served when applying for our company's Customer Services.

With Facade Pattern, Client only need to create Customer Information, then calls FacadeService setServiceforCustomer() method. All works containing register information, Consultation Service and HealhCare Service will be processed behind.
facade-pattern-demo

2. Step by Step
2.1- Create Customer class:

package com.javasampleapproach.facade.pattern;

public class Customer {

    private String name;

    public Customer(String name) {
        this.name = name;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    @Override
    public String toString() {
        return "Customer [name=" + name + "]";
    }
}

2.2- Create ICustomerService interface:

https://grokonez.com/design-pattern/facade-pattern-java

Facade Pattern in Javahttps://grokonez.com/design-pattern/facade-pattern-java

Facade Pattern in Java

Facade Pattern is a Structural Pattern in which, a set of interfaces is gathered into only one interface that Client can work easily and simply. Facade Pattern helps us to wrap complexities of components inside and lose coupling between Client and subSystems.

I. OVERVIEW

Facade Pattern defines a higher interface/object - Facade - that wraps some lower interfaces/objects. Whenever Client wants to make a chain of complex actions which require many methods and interaction, it just call one simple Facade method, all operation can be done inside that method.
facade-pattern-overview
You can see that Facade object contains other interfaces/objects (A, B, C) and manages their operation by doWork() method.

II. PRACTICE

1. Project Overview
Assume that we have some operations such as: register, consultation, healthcare that a Customer will be served when applying for our company's Customer Services.

With Facade Pattern, Client only need to create Customer Information, then calls FacadeService setServiceforCustomer() method. All works containing register information, Consultation Service and HealhCare Service will be processed behind.
facade-pattern-demo

2. Step by Step
2.1- Create Customer class:

package com.javasampleapproach.facade.pattern;

public class Customer {

    private String name;

    public Customer(String name) {
        this.name = name;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    @Override
    public String toString() {
        return "Customer [name=" + name + "]";
    }
}

2.2- Create ICustomerService interface:

https://grokonez.com/design-pattern/facade-pattern-java

Facade Pattern in Java

Bình luận


White
{{ comment.user.name }}
Bỏ hay Hay
{{comment.like_count}}
Male avatar
{{ comment_error }}
Hủy
   

Hiển thị thử

Chỉnh sửa

Male avatar

loveprogramming

545 bài viết.
98 người follow
Kipalog
{{userFollowed ? 'Following' : 'Follow'}}
Cùng một tác giả
Male avatar
1 0
Tutorial Link: (Link) (Ảnh) Django is a Pythonbased free and opensource web framework that follows the modeltemplateview architectural pattern. A...
loveprogramming viết 7 tháng trước
1 0
Male avatar
1 0
https://loizenai.com/angular11nodejspostgresqlcrudexample/ Angular 11 Node.js PostgreSQL Crud Example (Ảnh) Tutorial: “Angular 11 Node.js Postg...
loveprogramming viết 6 tháng trước
1 0
Male avatar
1 0
Angular Spring Boot jwt Authentication Example Github https://loizenai.com/angularspringbootjwt/ (Ảnh) Tutorial: ” Angular Spring Boot jwt Authe...
loveprogramming viết 6 tháng trước
1 0
{{like_count}}

kipalog

{{ comment_count }}

bình luận

{{liked ? "Đã kipalog" : "Kipalog"}}


Male avatar
{{userFollowed ? 'Following' : 'Follow'}}
545 bài viết.
98 người follow

 Đầu mục bài viết

Vẫn còn nữa! x

Kipalog vẫn còn rất nhiều bài viết hay và chủ đề thú vị chờ bạn khám phá!