Mailing List Archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [tlug] Constructed state, unit tests and REPLs

On 2020-09-03 09:59 +0200 (Thu), Josh Glover wrote:

> I write veeeeeery few unit tests these days, since REPL-driven development
> frees me from the test-driven development that I found extremely useful in
> languages like Java and Scala.

That seems...odd. Do you not write tests because the code is "tested"
sufficiently from indspection? In that case, what use is the REPL? Or do
you test in the REPL? If so, doesn't get tedious typing the same tests over
and over again when you could just type them once and let them be run

These days I find even even switching to a REPL or command line to be too
tedious; I usually just have the tests for whatever bit I'm working on run
every time a source file is written. I don't know how I used to put up with
moving my mouse pointer to another window, typing Esc, k, and then moving
my muse pointer back again every time I wanted to run the tests, even
though there's only one movement away from the home row in all of that. (I
use a TrackPoint.)

> I mainly develop the functions, write property-based tests, and then write
> a few example-based tests (AKA unit tests) for public functions to show
> people the intention of the functions and how to use them.

Yeah, that's what I can't really figure out. If you feel the need for
property-based tests (or any kind of tests), why not write them first? Then
you needn't muck about so much with a REPL: you can just let them continue
to run as you code.

> I also document public functions, unless the function and argument names
> are so obvious that documentation would just be restating what's already
> there. ;)

Well, I certainly don't write documentation for obvious stuff either, That
makes most of my documentation actually design work, so that gets written
first, and it's usually a plurality of the work. Almost invariably
documentation and tests are each more time and work than writing the code
that will run in production.

> I use the ipython REPL quite a bit when developing Python, and find it
> fairly decent for the way I want to work, but the Emacs integration isn't
> there to let me quickly evaluate code and keep going. I lean heavily on
> ipython's history search.

Ironically, it sounds as if I'm somewhat _more_ integrated than you, since
I just type into vim, hit `s` to save, and see the results of everything in
an adjacent window.

> It would be cool if we lived in a world where you and I could sit side by
> side and hack code, because it would be genuinely interesting for me to see
> how you work. I really enjoy watching experienced developers work. :)

Well, we do live in such a world so long as you're willing to use a few
tmate windows and Telegram voice chat. (The majority of my pair programming
outside of work has been remote like this for years now.) Poke me on
Telegram at @cjs_cynic if you want to try it out. (Or Google Hangouts/Meet
will probably also work, albeit it's somewhat more heavyweight. My e-mail
address finds me there.)

Curt J. Sampson      <>      +81 90 7737 2974

To iterate is human, to recurse divine.
    - L Peter Deutsch

Home | Main Index | Thread Index