Feed on
Posts
Comments

My favorite part is the refactoring.

Sometimes I do it by itself, as in the DoubleDawg. Mostly, though, I do it inline as part of the TDD discipline. I love it either way, and I can’t explain why.

Loving refactoring so openly is good good good when I’m coaching: other people can’t help but watch what I’m doing and then try to see if it’s really as fun as all that. (It is.)

But once a team jumps into the act itself, there’s a question that just has to pop into some minds, especially the ones who feel it’s very important to, you know, ship:

How Do I Know When I’m Done Refactoring?

“You’re done refactoring when the code meets our current standard of coding excellence.”

I’m always surprised when someone just nods their head to this and turns away, as if I’ve actually given an answer. I guess questions can sometimes be pro forma gestures, too.

Anyway, that’s a terrible answer, but on good days it leads right to the next question: What’s our current standard of coding excellence?

The Challenges Of Standard-Setting

Setting standards seems to cry out for the clarity and detail of a perfectly written set of rules. Ya know? If we just sat down and carefully listed all the things you can do, and all the things you can’t do, using maximum simplicity and maximum clarity, we’d have a perfect standard.

Then there are those of us who have either studied law, or babysat a truculent nine-year-old, or both.

  1. We want our rules to cover everything, but only a small handful of situations can really be described that way.
  2. We want our rules to be stable, but time and experience make mockery of our earlier attempts, time and again.
  3. We want our rules to be axiomatic, but as Kurt Godel demonstrated, any such that are sufficiently powerful to be of interest are also suffiicently powerful to contain undecidable propositions.
  4. We want our rules to be simple and no-nonsense, but as any handy nine-year-old can demonstrate, when it comes to misinterpretation, where there’s a will there’s a way.

So? What to do?
Henceforth for such or ED shaped individuals one of the best and the exact type of treatment i.e. cialis tabs 20mg a little small pill. cialis is additionally with advantages includes men’s certainty for sexual execution as due intersection their fulfillment for themselves and also for their fancied accomplice however just with single swallowing of a pill. cialis 10 mg 100mg arrives in a quality of 100mg that. As there levitra without prescription is no side effect, men can take advantage of generic anti-impotency drugs and save money while using the bestselling ED medicines. The attitude pertaining ED has undergone a sea change ordering levitra over the past few years. The drug doesn’t cause an erection viagra best buy but makes the body respond to stimulation.

The Simplest Thing That Could Possibly Work

When I first studied the XP process, I was struck by Kent Beck’s ability to construct rules that were as perfectly detailed as they could be, but no further.

“Do The Simplest Thing That Could Possibly Work” is a wonderful example of this.

Without a rigorous definition of simplest, possibly, and work, a computer would find this rule absolutely empty. All the important words in the rule are left to individual human judgment. Defining them would take years and years and would still fail. (Read the XP list some time.)

But the rule works in spite of the uncertainty, because it contains an implicit ‘you’ for each of the ambiguous words. Simplest means simplest-to-you, and possibly means possibly-to-you, and work means work-the-way-you-want.

Notice that this kind of rule completely evades the problems list from above. Clever.

My Rule For Refactoring

You are done refactoring when you’re ready to project the code onto the wall for the whole team to see.

This rule works just like the XP ones: it is full of opinion, judgment, and you-ness.

This rule works best when its coupled with actual code projection, along the lines of a lottery learning session.

I like that we simultaneously release the team, empowering them to decide for themselves what’s enough, and also situate them, showing them that their coding standard is going to be super-local, theirs and theirs alone.

I also love that I get to watch the actual meaning of that rule change. Every actual projected code session makes changes to the underlying meaning, and so do most pairing sessions between a junior and a senior.

Use The Projector Rule

To Identify The Moving Target Code Standard

4 Responses to “The Projector Rule: A Moving Target Code Standard”

  1. Joshua Lewis says:

    One way I tried to implement some semblance of this was to suggest the (team-owned and imposed) rule of no code promotions without a peer review for readability (I touched on this in my comment to the Lottery Learning post).

    I.e. if I’m not positive that I could maintain (read understand) that code should person get run over by a bus, I don’t want it in our QA branch (or even in dev/main). I don’t care about correctness at this point, only readability/understandability.

    For me, code readability encapsulates a lot implied by ‘code quality’ or ‘high standard of code’. At the least, for me that’s the starting point, or the absolute minimum.

    The way I try to explain this so I don’t across as patronising is to say that I’m quite stupid and the code needs to be easy to understand for a stupid guy like me.

    (As mentioned in my comment on Lottery Learning, the suggestion caused a massive debate and was not adopted – which is fine for now.)

    • GeePawHill says:

      Joshua… I’m still trying to think of how the team can work together to a) establish the ever-rising bar, and b) to have fun while doing it. Last time you were talking about projecting some of your own code, to get the ball rolling. Any luck with that? — GeePaw

      • Joshua Lewis says:

        Not yet unfortunately 🙁
        Though I’ve recently run into some more fundamental issues within the team (small design tenets that are missing), so I’m pushing to have some kind of session quite soon.

  2. I have a yes-but-no-but reaction to this (see also: yabitting 🙂 ). Yes, your code should be good enough that you feel proud when you show it to your colleagues. No, but your code needs the projector the most when you’re so ashamed of it you want to go and hide in a dark corner somewhere…

    Your colleagues should always be prepared to help you improve your code. Programming is a learning activity. I write bad code from time to time. That is, I know it sucks at the moment I wrote it, and may have an idea why but don’t know how to make it better. In hindsight my code often sucks, but I just didn’t know any better at the time…