当前位置: 首页 > wzjs >正文

网站源代码下载工具关键词挖掘站长

网站源代码下载工具,关键词挖掘站长,乐山市建设局网站,面板安装wordpress目录 定义结构适用场景使用示例 定义 外观模式(Facade Pattern)‌ 是一种结构型设计模式,它提供了一个统一的接口,用来访问子系统中的一组接口。外观模式定义了一个高层接口,这个接口使得子系统更容易使用。 结构 适用…

目录

  • 定义
  • 结构
  • 适用场景
  • 使用示例

定义

       外观模式(Facade Pattern)‌ 是一种结构型设计模式,它提供了一个统一的接口,用来访问子系统中的一组接口。外观模式定义了一个高层接口,这个接口使得子系统更容易使用。

结构

在这里插入图片描述

适用场景

       1)为复杂的子系统提供简单入口
       2)统一管理系统中存在的多个复杂的子系统
       3)解耦客户端与多个子系统之间的依赖关系
       4)分层系统中,作为层与层之间的通信接口
       5)为遗留系统提供新的简化接口

使用示例

      简单的电商订单示例
      定义各个模拟子系统

/*** 库存子系统*/
public class InventoryService {public boolean checkStock(String productId, int quantity) {System.out.println("检查库存: 产品" + productId + " 数量" + quantity);return true;}public void lockStock(String productId, int quantity) {System.out.println("锁定库存: 产品" + productId + " 数量" + quantity);}}
/*** 通知子系统*/
public class NotificationService {public void sendConfirmation(String userId, String orderId) {System.out.println("发送确认通知: 用户" + userId + " 订单" + orderId);}}
/*** 支付子系统*/
public class PaymentService {public boolean processPayment(String userId, double amount) {System.out.println("处理支付: 用户" + userId + " 金额" + amount);return true;}}
/*** 物流子系统*/
public class ShippingService {public String scheduleDelivery(String orderId) {String trackingNo = "TRK" + System.currentTimeMillis();System.out.println("安排配送: 订单" + orderId + " 物流单号" + trackingNo);return trackingNo;}}

      定义外观门面

/*** 外观:订单处理门面*/
public class OrderProcessFacade {private InventoryService inventory;private PaymentService payment;private ShippingService shipping;private NotificationService notification;public OrderProcessFacade() {this.inventory = new InventoryService();this.payment = new PaymentService();this.shipping = new ShippingService();this.notification = new NotificationService();}// 统一订单处理接口public String placeOrder(String userId, String productId, int quantity, double amount) {System.out.println("\n开始处理订单...");if (!inventory.checkStock(productId, quantity)) {throw new RuntimeException("库存不足");}inventory.lockStock(productId, quantity);if (!payment.processPayment(userId, amount)) {throw new RuntimeException("支付失败");}String orderId = "ORD" + System.currentTimeMillis();String trackingNo = shipping.scheduleDelivery(orderId);notification.sendConfirmation(userId, orderId);System.out.println("订单处理完成: " + orderId);return orderId;}}

      测试

public class OrderController {public static void main(String[] args) {OrderProcessFacade orderFacade = new OrderProcessFacade();String orderId = orderFacade.placeOrder("user123", "prod1001", 2, 299.99);System.out.println("生成的订单号: " + orderId);}}
http://www.dtcms.com/wzjs/393437.html

相关文章:

  • wordpress关闭伪静态专业搜索引擎优化电话
  • 电商网站支付方案创建app平台
  • seo网络优化软件百度seo优
  • 做动态图片的网站吗企业网络推广方案策划书
  • 在网站上做网络课堂软件多少钱合肥seo报价
  • 烟台广告公司网站建设链接式友谊
  • 企业的网站建设怎么记科目网站注册查询
  • 网站建设发展竞价排名是什么意思
  • 平面设计图数字标识搜索引擎内部优化
  • 自己电脑上做网站别人访问网站制作app
  • 大型游戏门户网站织梦模板站内seo和站外seo区别
  • 长沙网站建设王道下拉惠西安做推广优化的公司
  • 电子商务网站设计分析怎么做今日热点事件
  • 怎样做网站赚流量网络营销方案有哪些
  • 公司电子商务网站建设策划书seo sem
  • 房地产最新利好消息seo怎么优化方案
  • 河南商丘网站谷歌广告代理
  • 做eso哪家网站好推广营销方案
  • 微网站如何做微信支付宝支付宝重庆二级站seo整站优化排名
  • wordpress图片主题晨曦seo入门培训教程
  • 郑州做网站优化的公百度秒收录排名软件
  • 专业做网站产品上架的有吗室内设计培训哪个机构比较好
  • 上海专业高端网站建设搜索引擎推广
  • 个人网站 可以做论坛吗百度基木鱼建站
  • 中山视角做网站的公司网络营销成功案例ppt
  • 有没有手机可以看的网站免费的seo是什么意思中文翻译
  • 女装网站源码 带支付接口google搜索引擎免费入口
  • 郑州建设网站定制爱站工具seo综合查询
  • 网站当前位置怎么做seo站长工具综合查询
  • 衡水做网站推广的公司好用的搜索引擎