Proxy_Pattern

package proxy_pattern;

public interface Subject {
    public abstract void Request();
}

package proxy_pattern;

public class RealSubject implements Subject {
    @Override
    public void Request() {
        System.out.println("This is the realRequest!");
    }
}

package proxy_pattern;

public class Proxy implements Subject {
    RealSubject realSubject;

    @Override
    public void Request() {
        if (realSubject == null) {
            realSubject = new RealSubject();
        }
        realSubject.Request();
    }
}

package proxy_pattern;

public class Main {
    public static void main(String args[]) {
        Proxy proxy = new Proxy();
        proxy.Request();
    }
}
/***
 * The proxy_pattern uses composite to invoke the real request indirectly.
 * In some degree,this way can be seen as a hide for the original object.
 * The proxy_class and original_class implement the same interface so as to
 * complete the action without the trace.
 * There are some application about the proxy_pattern:
 * The first is kind of Remote_Proxy,which means the proxy_object can represent
 * "a part" or "the whole" of the original_object with different address.
 * The second is Virtual_Proxy that create "huge" object temporarily,which can 
 * storage the "expensive" object in the aspect of initialization.Such as:Delayed page loading.
 * The third is Security_Proxy,which is used to control the original object's access authority.
 * The last is Intelligent_Guidance that processes the additional internal affairs.
 */

This is a general introduction to the 23 design patterns in chinese:
https://blog.csdn.net/GZHarryAnonymous/article/details/81567214

See more source code:[GZHarryAnonymous](https://github.com/GZHarryAnonymous/Design_Pattern)

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值