sql 避免除0错误_避免错误的5种简单方法

sql 避免除0错误

Every web developer makes bugs. I’ve made hundreds at least. Known ones. Some happen quite often so let’s write them down.

每个网络开发人员都会犯错误。 我至少赚了数百。 已知的。 有些事情经常发生,所以让我们写下来。

Early discovery of bugs will help reduce costs. The further the problem goes the fixing costs rise exponentially. Check the graph to see what’s your impact overall.

尽早发现错误将有助于降低成本。 问题进一步发展,固定成本呈指数增长。 查看图表以了解您的整体影响。

Image for post
Credits: https://xbsoftware.com/blog/why-should-testing-start-early-software-project-development/
鸣谢: https : //xbsoftware.com/blog/why-should-testing-start-early-software-project-development/

Fixing important bugs will make you a valuable team member. Team members will have more confidence in your fixing ability. Read on to find out what are the easy ways to avoid bugs.

修复重要的错误将使您成为有价值的团队成员。 团队成员将对您的修复能力更有信心。 继续阅读,找出避免错误的简便方法。

表格验证 (Form Validation)

Forms are crucial for every CRUD app. Pay attention to form changes, new fields, controller changes. Form related changes will most probably lead to unexpected behavior.

表单对于每个CRUD应用程序都至关重要。 注意表单更改,新字段,控制器更改。 与表单相关的更改很可能导致意外行为。

Let’s say you need a new form field. Correct the form validation right after. Check all the possible form inputs, check the validity of the new HTTP request. Shared forms also can lead to serious bugs, be sure to thoroughly check each page using the form.

假设您需要一个新的表单字段。 之后立即更正表单验证。 检查所有可能的表单输入,检查新HTTP请求的有效性。 共享表单也可能导致严重的错误,请确保使用表单彻底检查每个页面。

Frontend validation should be a bit loose, but the backend should cover the rest. Ensure that your validation covers all special, invalid characters and that limits are correct.

前端验证应该有点宽松,但是后端应该覆盖其余部分。 确保您的验证涵盖所有特殊无效字符,并且限制正确无误。

处理列表和地图 (Handling Lists and Maps)

Lists, maps are used in every web app, to present the data in a proper way. Bad handling can lead to serious troubles.

每个Web应用程序都使用列表和地图,以正确的方式显示数据。 处理不当会导致严重的麻烦。

Edge cases around lists are numerous. Possible errors for lists:

列表周围的边缘情况很多。 列表可能的错误:

  1. empty lists

    空清单
  2. displaying errors

    显示错误
  3. mapping errors

    映射错误
  4. reducing errors

    减少错误

In order to prevent bugs from list handling, create good coverage with unit tests. Edge cases are almost always problems with lists. Creating bad mapping or reducing can get bad values as output.

为了防止错误进行列表处理,请使用单元测试创​​建良好的覆盖范围。 边缘案例几乎总是列表的问题。 创建错误的映射或缩小可能会得到错误的值作为输出。

代码剩余 (Code Leftovers)

Code leftover happens a lot of the time. Removing some feature, or creating a new one can create that kind of code.

剩下的代码经常发生。 删除某些功能或创建新功能可以创建这种代码。

Tests should weed out leftover code. Check suspicious, unused code in order to discover bugs. Code leftovers can occur if you are jumping from one thought process to another.

测试应清除掉剩余的代码。 检查可疑的未使用代码以发现错误。 如果您从一个思考过程跳到另一个思考过程,则可能会残留代码。

处理条件 (Handling Conditions)

Naming conditions can often lead to problems. Difference between naming variablesetPropertyToTrue and disableCaptcha can help out a lot.

命名条件通常会导致问题。 命名变量setPropertyToTruedisableCaptcha之间的区别可以提供很多帮助。

Never use negative for flags. For example, notYetUsedProduct should be !usedProduct. This way you won’t run into pesky bugs with flags, especially if there are multiple conditions.

切勿对标志使用负号。 例如, notYetUsedProduct应该是!usedProduct 。 这样,您就不会遇到带有标志的令人讨厌的错误,尤其是在存在多个条件的情况下。

Avoid using ternary operators, in JavaScript, for example, to make debugging easier. Extract all flags into separate functions and variables. Working with separate conditions is easier and shows intent right away.

例如,避免在JavaScript中使用三元运算符,以简化调试过程。 将所有标志提取到单独的函数和变量中。 在单独的条件下工作更容易,并且可以立即显示意图。

测试边缘案例 (Test Edge Cases)

Follow the code and test it. Last but not least tip. Be sure to cover all the edge cases. Consult with other developers, try to find another approach of testing.

按照代码进行测试。 最后但并非最不重要的一点。 确保覆盖所有边缘盒。 与其他开发人员协商,尝试找到另一种测试方法。

谢谢阅读! (Thanks for reading!)

翻译自: https://medium.com/dev-genius/5-easy-ways-to-avoid-bugs-9ddbcc01f9ed

sql 避免除0错误

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值