Giter Site home page Giter Site logo

关于服务端代码质量 about pushdeer HOT 2 CLOSED

easychen avatar easychen commented on July 18, 2024
关于服务端代码质量

from pushdeer.

Comments (2)

easychen avatar easychen commented on July 18, 2024

首先欢迎贡献修正代码。然后api实现的确在编码规范性上有问题,除以下几个外表示赞同。

  1. paginate 使用页数作为分页,在增量很快的情况下,会导致数据偏移。采用since_id 没有这个问题。
  2. pushkey 是专有名词,特指 pushdeer 的 key。
  3. 9 我没看出来怎么就减少嵌套层级了,$device 为假时不是根本就没进入下一层吗?

from pushdeer.

mogody avatar mogody commented on July 18, 2024
  1. 学到了新东西,感谢~
  2. 专有名词的话这么写就没毛病
  3. 9 的话并不绝对,可以理解为是 “优先返回原则”,$device 为假的时候直接 continue,整个代码段就只有两个层级:foreach 和
    if;如果 $device 为真再处理逻辑,整个代码段就是三个层级:foreach、if、if;两三个层级的话其实没啥大的差别,但是层级多了就会很痛苦,算是最佳实践。但是 2 种写法都没有什么大的毛病,个人是更推荐优先 continue

from pushdeer.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.