加入收藏 | 设为首页 | 会员中心 | 我要投稿 宁德站长网 (https://www.0593zz.com/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 运营中心 > 建站资源 > 优化 > 正文

如何成为一名优秀的工程师(语义篇)

发布时间:2019-03-08 07:30:47 所属栏目:优化 来源:佚名
导读:副标题#e# 好的语义表达是团队协作中高效迭代的润滑剂,好的语义表达是线上未知代码问题排查的指南针。 本篇文章巨长,如果你比较懒,来我讲给你听(直播中有更多细节) 回放地址 看完这个还不过瘾?学习使你快乐?还想学习?快上车 不要让其他人读不懂你的代码

@method 的使用

  1. /** 
  2.  * @link http://manual.phpdoc.org/HTMLframesConverter/default/ 
  3.  * 
  4.  * @method static int search(string $query, $limit = 10, $offset = 0) 
  5.  */ 
  6. class SearchServiceProxy 
  7.     public static function __callStatic($method, $arguments) 
  8.     { 
  9.         if (!method_exists("SearchService", $method)) { 
  10.             throw new LogicException(__CLASS__ . "::" . $method . " not found"); 
  11.         } 
  12.  
  13.         try { 
  14.             $data = call_user_func_array(["SearchService", $method], $arguments); 
  15.         } catch (Exception $e) { 
  16.             error_log($e->getMessage()); 
  17.             return false; 
  18.         } 
  19.  
  20.         return $data; 
  21.     } 
  22. }  

@deprecated 使用 

  1. class SearchService 
  2.  
  3.     /** 
  4.      * @param string $query 
  5.      * @param int    $limit 
  6.      * @param int    $offset 
  7.      * 
  8.      * @return array 
  9.      * @deprecated 
  10.      */ 
  11.     public static function search(string $query, $limit = 10, $offset = 0) 
  12.     { 
  13.         return [ 
  14.             ["id" => 1, "aaa"], 
  15.             ["id" => 2, "bbb"], 
  16.         ]; 
  17.     } 
  18. }  

注释其他注意事项

注释解释张冠李戴,方法名更新,方法的功能业务注释没更新;复制别人的代码把 @author 信息也复制过来了,错误了还要把锅甩给别人。

注释更多参考 http://manual.phpdoc.org/HTML...

函数、方法

案例1

先说明一句,不好的代码不妨碍它成为一个优秀的软件。PHP MySQL 烂代码多的去了。

(编辑:宁德站长网)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!