发表文章

[Ruby] 重构目标 Refactor Goals[wabur]

ashmaroli 2017-10-9 25

这不是 bug 报告, 而是更多的检查表 (~ 路线图), 它将更新已存在的项目的状态, 并在基本代码被重构时使用新项目。
它还将作为将来对 WABuR 库的最佳选择的参考。

  • 初始化实用程序模块 WAB::Utils 以处理跨类的行为 WAB [#10]
  • 将常用方法抽象为实用程序模块 [#52], [#77]
  • 通过将检查替换为一个变量的 case..when 表达式, 从而提高 impl/data.rb 中的可读性 if..elsif..else 。[#13]
  • 使用子句语句替换条件分支, 其中适合 [#90]
  • 用 instance_variables 或常量替换全局变量
    通过将嵌套的 if..elsif..else 抽象到私有方法来提高可读性
    取代尤达的条件, 传统的条件会更优化

样式

  • 喜欢单一贯, 除非引号是需要的插值, 特殊字符 [#92]
  • 分配给条件块外部的变量 [#89]
原文:

This is not a bug report but more of a checklist (~ roadmap) that'll get updated with status of items already present, and with new items as the codebase gets refactored.
It'll additionally serve as a future reference to what's considered optimal for the WABuR library.

  • Initialize a Utility Module WAB::Utils to handle behavior across WAB classes [#10]
  • Abstract frequently used methods to the Utility module [#52], [#77]
  • Improve readability in impl/data.rb by replacing if..elsif..else with case..when expressions where the check is one variable. [#13]
  • Use clause statements to replace conditional branches, where fit [#90]
  • Replace global variables with instance_variables or constants
    Improve readability by abstracting nested if..elsif..else to private methods
    Replace Yoda conditions where conventional conditions would be more optimal

Styles

  • Prefer single-quotes consistently unless double-quotes are required for interpolation, special characters [#92]
  • assign to a variable outside the conditional block [#89]
相关推荐
最新评论 (0)
返回
发表文章
ashmaroli
文章数
4
评论数
27
注册排名
9242