Presentation is loading. Please wait.

Presentation is loading. Please wait.

CMP 讲义 2018 CMP设计哲学及基础概念 CMP推荐的4层代码结构.

Similar presentations


Presentation on theme: "CMP 讲义 2018 CMP设计哲学及基础概念 CMP推荐的4层代码结构."— Presentation transcript:

1 CMP 讲义 2018 CMP设计哲学及基础概念 CMP推荐的4层代码结构

2 CMP 设计哲学思想及基础概念 大道至简 - KISS – Keep It Simple Stupid 。
把(远程)API 抽象为 Class.Method(Parameters) 完全模式(Full Pattern):$remote_uri=$scheme://$host:$port/$entryPath/ index.php?_c=$className&_m=$methodName&… $s = web ($remote_uri, o2s($postdata)); $o = s2o($s); if( $o && $o[‘STS’]== ‘OK’ ){ //Expected STS OK }elseif($o[‘STS’]){ //other STS }else{ //unexpected case, build $o $o=array(‘STS’=>’KO’, errmsg=>$s); } 优雅模式(Elegant Pattern):$remote_uri=…./$_c.$_m.api?... 优雅实质就是 = 效果/代码量,代码量越少(通过不断抽象共性来实现)则越容易维护

3 推荐的4层结构 推荐4层结构,首层仅允许 ApiXXXX/WebXXXX/WapXXXX等(*用AppAuth过滤)
API层调用LGC层(业务抽象逻辑层) LGC层调用BIZ层(业务实体对象层) APP层包含ORM层(ORM类似DAO) 凡事均有例外,有时简单事情简单办,迷你项目可偷鸡 ** 比如说Biz层偷掉或者合并到Orm层,直接Lgc操作Orm层;甚至剪掉Lgc层直接Api层直接操作Orm层; 具体要看项目的规模!

4 CDN / Firewall / SQUID / ReverseProxy NGINX / APACHE / FPM
System Architecture GET FORM POST XML POST JSON POST HTTP/HTTPS CDN / Firewall / SQUID / ReverseProxy NGINX / APACHE / FPM WEB MODE Api Api Lgc Lgc Lgc CONSOLE MODE Biz Biz Biz =XX% Orm Biz Orm NonDB DB (Mysql/M$sql/Redis/Mongo/etc) Orm CMP System By cmpTech.info

5 相关说明 公开代码仓 私有代码仓 (由导师构建)


Download ppt "CMP 讲义 2018 CMP设计哲学及基础概念 CMP推荐的4层代码结构."

Similar presentations


Ads by Google