当前位置:网站首页>Static proxy mode
Static proxy mode
2022-06-26 05:59:00 【Mr.Rop】
// Static proxy pattern
/* * Real objects and proxy objects should implement the same interface * The proxy object is to represent the real role * */
// benefits :
// Proxy objects can do a lot of things that real objects can't
// Real objects focus on doing their own things
public class StaticProxy {
public static void main(String[] args) {
You you = new You();
you.HappyMarry();
System.out.println("===================");
WeddingCompany weddingCompany = new WeddingCompany(new You());
weddingCompany.HappyMarry();
}
}
interface Marry{
void HappyMarry();
}
class You implements Marry{
// Real role
@Override
public void HappyMarry() {
System.out.println("HappyMarry");
}
}
class WeddingCompany implements Marry{
// delegable role
private Marry target;
public WeddingCompany(Marry target) {
this.target = target;
}
@Override
public void HappyMarry() {
before();
this.target.HappyMarry();
after();
}
private void before() {
System.out.println(" The invitation , Site layout ");
}
private void after() {
System.out.println(" end , Closing payment ");
}
}
边栏推荐
- numpy.random.choice
- Some doubts about ARP deception experiment
- Soft power and hard power in program development
- 卷妹带你学jdbc---2天冲刺Day2
- Summary of the 10th provincial Blue Bridge Cup
- Yamaha robot splits visual strings
- Upgrading technology to art
- tf. nn. top_ k()
- 421-二叉树(226. 翻转二叉树、101. 对称二叉树、104.二叉树的最大深度、222.完全二叉树的节点个数)
- numpy. random. choice
猜你喜欢

On site commissioning - final method of kb4474419 for win7 x64 installation and vs2017 flash back

小程序如何关联微信小程序二维码,实现二码聚合

解决在win10下cmder无法使用find命令

Pytorch (network model training)

Ribbon load balancing service call

421-二叉树(226. 翻转二叉树、101. 对称二叉树、104.二叉树的最大深度、222.完全二叉树的节点个数)

How to use the tablet as the second extended screen of the PC

Kolla ansible deploy openstack Yoga version

小程序第三方微信授权登录的实现

家庭记账程序(第二版 加入了循环)
随机推荐
MobileNets: Efficient Convolutional Neural Networks for Mobile Vision Applications
电商借助小程序技术发力寻找增长突破口
Old love letters
工厂方法模式、抽象工厂模式
Some doubts about ARP deception experiment
pytorch(环境、tensorboard、transforms、torchvision、dataloader)
怎么把平板作为电脑的第二扩展屏幕
【C语言】深度剖析数据在内存中的存储
one billion two hundred and twelve million three hundred and twelve thousand three hundred and twenty-one
String class learning
MySQL database-01 database overview
转帖——不要迷失在技术的海洋中
tf.nn.top_k()
Gram matrix
Sql语法中循环的使用
The model defined (modified) in pytoch loads some required pre training model parameters and freezes them
卷妹带你学jdbc---2天冲刺Day2
C XX management system
numpy. tile()
MySQL-05