refactoring, unit testing, ant, etc.

John Roth newsgroups at jhrothjr.com
Wed Jun 8 20:48:17 EDT 2005


"Dave Rose" <s_david_rose at hotmail.com> wrote in message 
news:mailman.145.1118273529.10512.python-list at python.org...
> Hello all
>  I've been learning Python for the past few months, reading tutorials and
> postings here.  I've bought the personal Komodo then downloaded Eclipse 
> with
> Pydev.  IDLE also is a staple of everyday use.
>
>  ~10 years ago, I had CS as a minor in college.  I learned some C and 
> modula-2
> to name the relevent languages.  Back then I was compiling on a VAX.  Much
> different than today.
>
>  I was hoping someone could guide me a bit with current-day practices. 
> I've
> been pythoning along, but I hear about things I don't know about 
> (re-factoring,
> unit-testing, debugging, ant build tools) and I don't know how they're
> applicable to make my life easier.  Tutorials didn't shed too much 
> light -- 
> they make it seem to be more work than I need now.
>
>  To be clear, I've used debuggers in the past, but it seems when I set 
> break-
> points, the Eclipse just skips merrily past them, or steps at every line, 
> and
> for wxPython, that's annoying given all the support libraries.  I also use
> wxPython and wxGlade, so those seem to ignore debug mode completely for 
> some
> reason.
>
>  Can someone please shed some light onto how I should really use my IDE to
> make my life more enjoyable?  I feel I just don't know how to use the 
> tools
> that are available, and that's frustrating.

It's actually not an IDE issue (well, not much  of one). I never use
the debugger. The next thing to learn is probably Test Driven Development.
Kent Beck's book (Test Driven Development by Example) has an extended
example in Python as the second section.

TDD is simply the practice of writing a test, then writing the code to make
it pass, then writing another test and so forth. As long as you make sure
all the tests keep passing, whenever one of them breaks it's probably the
last edit you made, which makes it real easy to figure out what the problem
is and fix it.

The easiest way to ease into refactoring is to ruthlessly eliminate 
duplication
in your programs. One of the really interesting things about this is that 
you
can frequently see the right abstractions and design patterns just emerge
without having to design them up front. Doesn't always happen, but it does
often enough to be really gratifying.

The Python library contains a module named unittest which is the Python
equivalent of JUnit etc. I normally run my test suite out of a command line
that I keep open while I'm working. I think PyDev in Eclipse has support
for it, but since I don't use that I'm not at all sure.

John Roth

>
> Thanks so much!
> Dave
> 




More information about the Python-list mailing list