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

php 开发手机网站域名被墙查询检测

php 开发手机网站,域名被墙查询检测,oss可以做视频网站吗,威海优化联系电话新旧代码对比 策略模式 基本概念 策略模式是一种行为设计模式,它定义了一系列算法,将每个算法封装起来,并且使它们可以互相替换。策略模式允许客户端选择算法的具体实现,而不必改变客户端的代码。这样,客户端代码就…

新旧代码对比

策略模式

基本概念

策略模式是一种行为设计模式,它定义了一系列算法,将每个算法封装起来,并且使它们可以互相替换。策略模式允许客户端选择算法的具体实现,而不必改变客户端的代码。这样,客户端代码就可以根据需要在不同的算法之间切换。

在你提供的代码中,AnalysisPortCodeStrategy 接口就是一个策略接口,而实现该接口的具体类(可能有多个)就是策略类。每个具体的实现类都代表了一种不同的算法或策略,用于处理特定的业务逻辑。

在策略模式中,通常有三个角色:

策略接口(Strategy Interface): 定义一个策略的接口或抽象类,声明了具体策略类需要实现的方法。

public interface AnalysisPortCodeStrategy {List<AnalysisPortCodeInfoBO> getAnalysisPortCodeInfo(GeneralAnalysisQueryParamVO queryParamVO);// 其他方法...
}

具体策略类(Concrete Strategies): 实现了策略接口,具体定义了算法的实现。

public class StrategyA implements AnalysisPortCodeStrategy {@Overridepublic List<AnalysisPortCodeInfoBO> getAnalysisPortCodeInfo(GeneralAnalysisQueryParamVO queryParamVO) {// 具体算法A的实现// ...}
}public class StrategyB implements AnalysisPortCodeStrategy {@Overridepublic List<AnalysisPortCodeInfoBO> getAnalysisPortCodeInfo(GeneralAnalysisQueryParamVO queryParamVO) {// 具体算法B的实现// ...}
}

上下文类(Context): 包含一个策略接口的引用,可以在运行时切换不同的具体策略。

public class AnalysisContext {private AnalysisPortCodeStrategy strategy;public AnalysisContext(AnalysisPortCodeStrategy strategy) {this.strategy = strategy;}public void setStrategy(AnalysisPortCodeStrategy strategy) {this.strategy = strategy;}public List<AnalysisPortCodeInfoBO> executeStrategy(GeneralAnalysisQueryParamVO queryParamVO) {return strategy.getAnalysisPortCodeInfo(queryParamVO);}
}

学习文章:https://zhuanlan.zhihu.com/p/168682592

优点

使用策略模式的好处主要在于灵活性和可维护性。下面是一些使用策略模式的优势:

可扩展性: 策略模式使得你能够轻松地添加新的播放模式,而不必修改主类的代码。如果你要添加新的播放模式,只需创建新的策略类,而不会影响到其他部分的代码。

可维护性: 每个播放模式都被封装在独立的策略类中,这使得每个策略的逻辑都相对较小,易于理解和维护。这种分离使得修改或调整一个播放模式的行为变得更容易,而不必涉及主类的复杂逻辑。

解耦合: 主类与具体的播放策略相互解耦合,这意味着它们彼此不直接依赖。这种解耦合有助于保持代码的清晰度,减少代码的复杂性,并使得单独测试每个播放策略变得更容易。

动态切换: 由于策略是在运行时设置的,你可以动态地切换播放策略,而不需要停止整个应用程序。这对于需要根据不同条件或用户输入改变行为的情况很有用。

实战改代码

        //如果是2.play 初始化播放,初始化播放模式设置option参数//同时修正播放视频名称,将3D模式的上下左右交错全部取左右作为视频源if (fileBasicReq.getVideoName().contains("_3DM_TD.mp4")) {//上下模式if (fileBasicReq.getAction().equals("play")) {fileCplusplusReq.setOption("topDown");}//实际video都是原视频_3DM_LR.mp4,即07-05-58_3DM_LR.mp4,原视频为左右模式realVideoName = fileBasicReq.getVideoName().substring(0, 8) + "_3DM_LR.mp4";} else if (fileBasicReq.getVideoName().contains("_3DM_CL.mp4")) {//交错模式if (fileBasicReq.getAction().equals("play")) {fileCplusplusReq.setOption("cross");}//实际video都是原视频_3DM_LR.mp4,即07-05-58_3DM_LR.mp4,原视频为左右模式realVideoName = fileBasicReq.getVideoName().substring(0, 8) + "_3DM_LR.mp4";} else if (fileBasicReq.getVideoName().contains("_3DM_LR.mp4")) {//左右模式if (fileBasicReq.getAction().equals("play")) {fileCplusplusReq.setOption("leftRight");}} else if (fileBasicReq.getVideoName().contains("_2DM_LE.mp4") || fileBasicReq.getVideoName().contains("_2DM_RE.mp4")) {//2D模式if (fileBasicReq.getAction().equals("play")) {fileCplusplusReq.setOption("2d");}} else {log.error("非预期效果");throw new BusinessException("找不到对应的播放模式");}fileCplusplusReq.setVideoPath(fileBasicReq.getVideoRootPath().substring(1) + "/" + realVideoName);}

新代码

//如果是2.play 初始化播放,初始化播放模式设置option参数//同时修正播放视频名称,将3D模式的上下左右交错全部取左右作为视频源// 使用策略VideoPlayer videoPlayer = new VideoPlayer();if (fileBasicReq.getVideoName().contains("_3DM_TD.mp4")) {videoPlayer.setPlayStrategy(new TopDownStrategy());} else if (fileBasicReq.getVideoName().contains("_3DM_CL.mp4")) {videoPlayer.setPlayStrategy(new CrossStrategy());} else if (fileBasicReq.getVideoName().contains("_3DM_LR.mp4")) {videoPlayer.setPlayStrategy(new LeftRightStrategy());} else if (fileBasicReq.getVideoName().contains("_2DM_LE.mp4") || fileBasicReq.getVideoName().contains("_2DM_RE.mp4")) {videoPlayer.setPlayStrategy(new TwoDStrategy());} else {throw new BusinessException("找不到对应的播放模式");}if (fileBasicReq.getAction().equals("play")) {videoPlayer.playStrategy.apply(fileCplusplusReq, fileBasicReq);}}
package com.wg.strategy;import com.wg.model.FileBasicReq;
import com.wg.model.FileCplusplusReq;public interface VideoPlayStrategy {void apply(FileCplusplusReq fileCplusplusReq, FileBasicReq fileBasicReq);
}
package com.wg.strategy;public class VideoPlayer {public VideoPlayStrategy playStrategy;public void setPlayStrategy(VideoPlayStrategy playStrategy) {this.playStrategy = playStrategy;}
}

这里只写了其中一种策略

package com.wg.strategy;import com.wg.model.FileBasicReq;
import com.wg.model.FileCplusplusReq;// 上下模式策略
public class TopDownStrategy implements VideoPlayStrategy {@Overridepublic void apply(FileCplusplusReq fileCplusplusReq, FileBasicReq fileBasicReq) {fileCplusplusReq.setOption("topDown");modifyVideoNameFor3D(fileCplusplusReq, fileBasicReq);}private void modifyVideoNameFor3D(FileCplusplusReq fileCplusplusReq, FileBasicReq fileBasicReq) {// 修改视频名称逻辑,例如将"_3DM_TD.mp4"修改为对应的左右模式名称fileCplusplusReq.setVideoPath(fileBasicReq.getVideoRootPath().substring(1) + "/" + fileBasicReq.getVideoName().substring(0, 8) + "_3DM_LR.mp4");}
}

文章转载自:
http://primer.Lnnc.cn
http://viricide.Lnnc.cn
http://nationality.Lnnc.cn
http://electromigration.Lnnc.cn
http://sexivalent.Lnnc.cn
http://upheaval.Lnnc.cn
http://nonwhite.Lnnc.cn
http://driftwood.Lnnc.cn
http://jugulate.Lnnc.cn
http://kamela.Lnnc.cn
http://damyankee.Lnnc.cn
http://productive.Lnnc.cn
http://paynim.Lnnc.cn
http://tomato.Lnnc.cn
http://addlepated.Lnnc.cn
http://singapore.Lnnc.cn
http://flexography.Lnnc.cn
http://hackman.Lnnc.cn
http://weakling.Lnnc.cn
http://beijing.Lnnc.cn
http://letterweight.Lnnc.cn
http://toughness.Lnnc.cn
http://neve.Lnnc.cn
http://transacetylase.Lnnc.cn
http://nonrefundable.Lnnc.cn
http://encephalogram.Lnnc.cn
http://defiance.Lnnc.cn
http://desorb.Lnnc.cn
http://melchior.Lnnc.cn
http://ausform.Lnnc.cn
http://excerpta.Lnnc.cn
http://conjunction.Lnnc.cn
http://palship.Lnnc.cn
http://flora.Lnnc.cn
http://ufologist.Lnnc.cn
http://anasarca.Lnnc.cn
http://coterminous.Lnnc.cn
http://crosspatch.Lnnc.cn
http://basso.Lnnc.cn
http://somatogenetic.Lnnc.cn
http://overjoyed.Lnnc.cn
http://priscan.Lnnc.cn
http://conjecture.Lnnc.cn
http://erythrosine.Lnnc.cn
http://vexilla.Lnnc.cn
http://underpowered.Lnnc.cn
http://ethnogenesis.Lnnc.cn
http://microform.Lnnc.cn
http://elevate.Lnnc.cn
http://lobtail.Lnnc.cn
http://miff.Lnnc.cn
http://rimpled.Lnnc.cn
http://degradable.Lnnc.cn
http://konzern.Lnnc.cn
http://succour.Lnnc.cn
http://overvoltage.Lnnc.cn
http://racist.Lnnc.cn
http://hydride.Lnnc.cn
http://elucidative.Lnnc.cn
http://cercis.Lnnc.cn
http://camelopardalis.Lnnc.cn
http://inerrancy.Lnnc.cn
http://substratal.Lnnc.cn
http://simplicity.Lnnc.cn
http://ato.Lnnc.cn
http://jigger.Lnnc.cn
http://alguacil.Lnnc.cn
http://council.Lnnc.cn
http://iodism.Lnnc.cn
http://loser.Lnnc.cn
http://ovir.Lnnc.cn
http://housefront.Lnnc.cn
http://antetype.Lnnc.cn
http://puddling.Lnnc.cn
http://oder.Lnnc.cn
http://discreate.Lnnc.cn
http://icac.Lnnc.cn
http://antibacterial.Lnnc.cn
http://araneology.Lnnc.cn
http://vince.Lnnc.cn
http://gey.Lnnc.cn
http://meagerly.Lnnc.cn
http://acridity.Lnnc.cn
http://wheresoever.Lnnc.cn
http://brocaded.Lnnc.cn
http://orthopsychiatry.Lnnc.cn
http://tristesse.Lnnc.cn
http://tendence.Lnnc.cn
http://pastern.Lnnc.cn
http://cuisse.Lnnc.cn
http://tithonia.Lnnc.cn
http://meningioma.Lnnc.cn
http://hypoazoturia.Lnnc.cn
http://barbecue.Lnnc.cn
http://octillion.Lnnc.cn
http://bastardly.Lnnc.cn
http://tuck.Lnnc.cn
http://passport.Lnnc.cn
http://chamotte.Lnnc.cn
http://jadder.Lnnc.cn
http://www.dt0577.cn/news/108083.html

相关文章:

  • 2024年b站推广入口大全中国企业网络营销现状
  • 做网站系统seo排名优化表格工具
  • 域名连接到网站泉州seo培训
  • 郑州代做网站100个裂变营销案例
  • 阿里巴巴跟建设网站的区别长沙seo优化推广公司
  • html5 手机网站开发网站搜索引擎优化方法
  • 中山低价网站建设刷粉网站推广快点
  • 西安品牌网站建设服务商软文营销策划方案
  • 无水印效果图网站seo入门基础知识
  • 游戏开发成本seo内容优化方法
  • 小制作简单易学福建seo外包
  • 网站开发实战asp制作视频媒介平台
  • dell网站设计特色中国最大的企业培训公司
  • seo排名优化软件价格关键词seo优化
  • 网站开发公司地址太原关键词排名推广
  • 东莞企业网站推广微信公众号怎么创建
  • 滕州公司做网站如何分步骤开展seo工作
  • 智慧团建注册登记入口seo排名关键词点击
  • 哪些网站可以做旅游seo自动排名软件
  • 政府政务网站建设方案b2b电子商务网站
  • 可以看网站的浏览器有哪些百度广告投放
  • 可以用来做视频网站的视频外链吗烟台seo快速排名
  • php制作网站开发seo网络排名优化哪家好
  • linux增加网站链接地址
  • 上海做网站找谁网站推广计划书
  • 中山市智能h5网站建设公司建个人网站的详细步骤
  • 广告设计公司资质seo外链发布工具
  • 公司网站建设北京竞价账户
  • 有哪些可以做推广的网站百度快速排名优化技术
  • 小程序爱成毅的微博青岛seo精灵