[TIP] Doctest or unitest?
Andrew Bennetts
andrew-tip at puzzling.org
Mon Mar 5 16:24:57 PST 2007
Michael Foord wrote:
> Andrew Bennetts wrote:
> >
> >I find even normal code can have extremely obscure intent. The "how" is
> >always obvious (that's what code is), but the intent needs explicit care from
> >the author if it is to be communicated to the next person to look at the
> >code. Good habits in naming of identifiers and the like obviously go some
> >way to helping here, so that taking this care becomes somewhat automatic, but
> >it needs to be taken.
> >
>
> I actually disagree with this fairly strongly.
>
> I think good, well written code *can* communicate intent.
>
> This is part of the point about 'DSL's. We have the flexibility in
> dynamic languages to write code that communicates as well as performing
> a function.
>
> (For example) At Resolver our policy is to comment code as little as
> possible - if you can't work out the intent of code then it is badly
> written. Only in particularly obscure parts of the code (i.e. almost
> everywhere we interact with win32 stuff!) do we comment.
I don't see any part of what you say here that disagrees with what I said (or
what I think I said...).
Good, well written code absolutely can communicate intent — but if the author
doesn't take care to make the code be good and well written, then the the intent
won't be clear.
Using a domain specific language can help, but it's no magic bullet.
-Andrew.
More information about the testing-in-python
mailing list