Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Catching typos in scripting languages

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?

like image 721
Geo Avatar asked Mar 21 '10 12:03

Geo


People also ask

How do you avoid typos in programming?

You need to use IDE for your programming language. It will show your typos, and eventually suggest correct words. Also, using autocomplete option can help, if variable names are long.

What is typo in programming?

Short for typographical error, a typo is a mistake made in typed or printed text. Some quick examples are spelling occurrence with one 'c' or 'r,' or spelling 'receive' as 'recieve.

What are typos in Python?

typo is a python package to simulate typographical errors in English language.


1 Answers

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;-).

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;-).

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).

like image 86
Alex Martelli Avatar answered Oct 05 '22 22:10

Alex Martelli