Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

I post the origin question in stackoverflow, some people suggest me to post here

I've always have trouble with dynamic language like Python.

Several problems:

  1. Typo error, I can use pylint to reduce some of these errors. But there's still some errors that pylint can not figure out.
  2. Object type error, I often forgot what type of the parameter is, int? str? some object? Also, forgot the type of some object in my code.

Unit test might help me sometimes, but I'm not always have enough time to do UT. When I need a script to do a small job, the line of code are 100 - 200 lines, not big, but I don't have time to do the unit test, because I need to use the script as soon as possible. So, many errors appear.

So, any idea on how to reduce the number of these problems?

share|improve this question
2  
If you had waited for a moment your question would probably have been migrated for you. –  Martijn Pieters Dec 5 '12 at 12:09
    
If you don't have time to test, would you have time to write and update your type annotations in a more static language? Or sit through lengthy compile cycles? –  Antimony Jun 6 '13 at 6:35
    
@Antimony A 100-200 line program should compile in less than a second or so (depending on the language and breadth of libraries used of course). The compile time is likely not to be particularly "lengthy." –  skyler Aug 13 '13 at 2:04
add comment

3 Answers

up vote 3 down vote accepted

I'm afraid there's nothing better than unit tests in this case. Sometimes extensive comments (for every method, and sometimes even for a given line of code) help, but it only postpones the inevitable doom :)

Of course good comments are always helpful, no matter the unit tests exist or not.

share|improve this answer
    
Ok, I will try to add more unit test, thanks –  jiluo Dec 6 '12 at 5:29
add comment

For the object type problem you could use Hungarian Notation. Most programmers I know (including myself) think it's ugly, but if that's often recurring problem for you, this would most likely work.

For typo errors a IDE or Texteditor with syntax highlighting, code completion and similar functionality could help if you don't use this already.

share|improve this answer
add comment

Well, most (but not all) of these problems can and should be managed by the IDE, not by the programmer.

Maybe you are just using an IDE that is not good enough for the task at hand.

Did you try IntelliJ IDEA, for example?

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.