fhwang.net

How necessary is refactoring?

So, yeah, I get into a lot of discussions about mocks, and why I almost never use them in testing. One of the reasons I give is that I often end up having to do extensive refactoring if I get the overall structure of the code wrong the first time.

I feel like there’s a deeper issue, which might lead to some of the disagreement, which is this: How difficult is it to do a decent design of your code the first time ‘round? If you rarely have to do significant refactoring, then maybe mocking is worth it.

So maybe this’ll demonstrate where I’m coming from:

[admin_assistant (master)]$ git log

commit fdb3c373b69d27e0f9410302836f51de2aef7cfe
Author: Francis Hwang <sera@fhwang.net>
Date:   Sat Mar 14 09:41:43 2009 -0700

    Rrrrrrrr

commit f21355213b636f496314413939b41efb4a7819d7
Author: Francis Hwang <sera@fhwang.net>
Date:   Sat Mar 14 09:30:44 2009 -0700

    don't stop the body rock

commit 81a5ea273d47663525f16e6336fa1fe87f40c3a0
Author: Francis Hwang <sera@fhwang.net>
Date:   Sat Mar 14 09:19:53 2009 -0700

    rhifahct0rr

commit 5d07bd7b5ffd864315867d9f697dcaa501a748e5
Author: Francis Hwang <sera@fhwang.net>
Date:   Sat Mar 14 09:04:09 2009 -0700

    the R-word

commit 36f667199cab32c4ac4ba02b209f456996f34746
Author: Francis Hwang <sera@fhwang.net>
Date:   Sat Mar 14 00:25:13 2009 -0700

    r3f4ct0r

commit d82586bbf4d5a429749e6e2769701031ef7b1b2b
Author: Francis Hwang <sera@fhwang.net>
Date:   Sat Mar 14 00:11:42 2009 -0700

    rearranging deck chairs

commit 9440c364b161455cf095a1a9e33381e715e29564
Author: Francis Hwang <sera@fhwang.net>
Date:   Fri Mar 13 18:32:43 2009 -0700

    refactor

commit 2194a9c80bc0ed10cbb5a7e878b32dd0c867c66a
Author: Francis Hwang <sera@fhwang.net>
Date:   Fri Mar 13 14:31:55 2009 -0700

    rfctr

commit 64a8a4325cdfb083b04ac0de763935b755555e9f
Author: Francis Hwang <sera@fhwang.net>
Date:   Fri Mar 13 09:01:19 2009 -0700

    refact0r

commit 756b023a1fa249cb15e8839bb1538c36e107a79b
Author: Francis Hwang <sera@fhwang.net>
Date:   Fri Mar 13 08:49:59 2009 -0700

    refacteezy

commit e9f5898a76a9a4b1c678f6c3e6e9a71618ac59a9
Author: Francis Hwang <sera@fhwang.net>
Date:   Thu Mar 12 10:06:29 2009 -0700

    refactor

This is for admin_assistant, my very-alpha replacement for ActiveScaffold. I made 11 commits in a row that didn’t add any functionality, they only tried to preserve existing functionality while expressing the problem more clearly. Why is that?

  • Francis is insanely OCD, and this git log is the coder’s equivalent of a girl going over her face with a magnifying mirror and a pair of tweezers,
  • Francis is completely horrible at modeling simple problems and should probably go into a different line of work, like muffler repair,
  • Francis is working on a genuinely hard problem and finds that for this sort of thing, a slow, arduous crawl towards the right design leads to the best design in the end.

Obviously I think Door number 3 is true to a large extent but I could be just deluding myself. And, of course, they’re not mutually exclusive.

blog comments powered by Disqus
Tagged: software

« Previous post

Next post »