Java design mode--appearance mode (façade mode) (façade) __ Appearance mode

Source: Internet
Author: User

The

Appearance mode is intended to provide an interface for the subsystem to facilitate the use of
appearance classes, tool classes, and example classes
appearance classes may all be static methods
The sample class shows how to use the class and subsystem
The difference between the sample class and the Appearance class:
1, the example class is usually a stand-alone The appearance class is not
2, and the sample class contains sample data. The Appearance class does not have
3, the appearance class is usually configurable, the example class is not
4, the intent of the appearance class is for reuse, the example class is not
5, the skin class is used in the product code, and the sample class is not
Java with less appearance analogies, The reason is that
1, Java developers typically require a holistic understanding of the tools in the library, and the appearance pattern may limit the way the system is used. The
2, Java class Library provides few appearance classes.

public class Encryptfacade {

    private filereader reader;
    Private FileWriter writer;
    Private Ciphermachine cipher;

    Public Encryptfacade () {
        reader = new FileReader ();
        writer = new FileWriter ();
        cipher = new Ciphermachine ();
    }

    public void Fileencrypt (string filenamesrc,string filenamedesc) {
        string plainstr = Reader.read (FILENAMESRC);
        String encryptstr = Cipher.encrypt (PLAINSTR);
        Writer.writer (ENCRYPTSTR,FILENAMEDESC);
    }
/**
     * @author Shu Yuwei
     * @time 2015-2-7 a.m. 11:26:09
     * @param args * * Public
    static void Main (string[) args) {
        Encryptfacade façade = new Encryptfacade ();
        Facade.fileencrypt ("File Encryption", "appearance mode");
    }

I just need to invoke a good encapsulation method and provide the user with the available interface, as to how the interface inside the method is implemented without having to be shown to the user.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.