捕获脚本语言中的错别字 [英] Catching typos in scripting languages

查看:68
本文介绍了捕获脚本语言中的错别字的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果您选择的脚本语言没有类似Perl的严格模式,你抓错字了吗?您是否要对所有内容进行单元测试?每个构造函数,每个方法?这是唯一的解决方法吗?

If your scripting language of choice doesn't have something like Perl's strict mode, how are you catching typos? Are you unit testing everything? Every constructor, every method? Is this the only way to go about it?

推荐答案

真正彻底的单元测试是最重要的技术(是的,我一直以100%的覆盖率为目标),因为它们还会捕获许多其他错别字(例如,我写+的意思是-),不合一的问题,等等.行使每项功能的集成和负载测试是抵御各种错误的第二道防线(尽管大多数情况下,更深更难);- ).

Really-thorough unit tests are the most important technique (yes, I do always aim for 100% coverage), as they also catch many other typos (e.g. where I write + and meant -), off-by-one issues, etc. Integration and load tests exercising every feature are the second line of defense against all kinds of errors (mostly, though, deeper and harder ones;-).

接下来是诸如 pylint

Next are tools such as pylint and pychecker and colorizing editors (I don't use real IDEs, but they would also help similarly to how my trusty gvim editor does;-).

诸如强制性代码审查之类的技术(例如,CFR关于我的主题

Techniques such as mandatory code reviews (e.g., cfr a video of an interview of mine on the subject here), while crucial, should focus on other issues -- issues that automated tools just won't catch, such as completeness and correctness of comments/docstrings, choice of good/speedy algorithms, and the like (see here for a summary of the talk I gave on the subject at the same conference as I got that interview at, and a link to the slides' PDF).

这篇关于捕获脚本语言中的错别字的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆