Feed on
Posts
Comments

In this latest in the DoubleDawg series, I’m so close I can *taste* it.

The After Code for Step 6 (1318)

Get the Flash Player to see this content.

Code After Step 7 (4040)

Previous DoubleDawgDare

Next DoubleDawgDare

11 Responses to “DoubleDawgDare 7: One Spike, No Buffy”

  1. nico says:

    Thank you so much for recording this, GeePaw!
    nico

  2. Jeff Grigg says:

    Most interesting. Welcome back! Thanks!

    I notice that the spike used a slightly different approach than the final implementation: I’d say that the spike emphasized type safety while the “TDD implementation” emphasized reuse. I think it will be interesting to see how this works out over time.

    While some people think that refactoring should be driven by failing tests, I think it can be driven entirely by code smells. I’d say that test-driven is only necessary for adding functionality; not for changing implementation (IE: refactoring). Of course it’s never wrong to add tests; it just may not be necessary.

    • GeePawHill says:

      Jeff… True enough about the loss of type safety in the TDD’d version. Not at all sure what that means. I think I just realized that I’d have to have some annotations laying around if I were to keep the type. Since there was nothing actually annotation-specific, I let my deep fundamental laziness take over.

      I never refactor from a red bar. I strive, in fact, to always go green-to-green over and over. I think those folks who work otherwise are confusing rewriting and refactoring. — Cheers, GeePaw.

  3. Jeff Grigg says:

    You’re not going to keep ignoring your granddaughter’s complaints about the three ‘getter.getString(“fieldName”)’ calls in a row, are you? “Oww! It hurts my eyes!”, she may say. ;->

    (What if there where a ‘fieldName’ method in the FieldGetter class? 😉

    (And if FieldGetter is good for the processRegexFieldValidator method, then it might be good for the other 39 calls that look like ‘v.fieldName()’ too. 😉

  4. Jeff Grigg says:

    As an experiment, I extended FieldGetter to be a drop-in replacement for the annotation “v” variables. Then I dealt with Feature Envy by extracting methods and moving them to FieldGetter. Since nearly all the differences between the “process*Validator” methods are due to the different field accessors available on each annotation, and that the null checking logic complements FieldGetter’s handling of missing fields, I was able to move nearly everything over to FieldGetter and inline the “process*Validator” methods into their callers.

    The AnnotationValidationConfigurationBuilder class went from 689 lines to 354 lines. FieldGetter grew from 36 lines to 192 lines. Plus the addition of a simple interface (StringFilter) with two implementations.

    It’s a heavily reflection-based implementation. It’s shorter, but definitely much trickier. I’m not entirely convinced that it’s the best result possible.

    To see my code, start with your “ddd7after.zip” files, and then add in my files (mix in the “src” and “tst” directories) from the “2010-05-09 – ddd7after – JeffGrigg Changes Only.zip” file at http://tech.groups.yahoo.com/group/extremeprogramming/files/Discussion/

  5. Jeff Grigg says:

    Re: “I’m so close I can *taste* it.”

    So does it taste like chicken? ;->

    • Jeff Grigg says:

      (I did *not* mean that as an insult.)

      You have an idea. I’d like to see you run with it! ;->

      • GeePawHill says:

        Ahhh, Jeff. Even if I *thought* you were being insulting, which I didn’t, I’d still think that you’ve carried your weight around this project, thus having certain rights.
        On the road right now, and I haven’t prepared my talk at Microsoft (couldn’t resist the brag) that happens on the way home. That has to be my priority this weekend.
        *But*, I freely admit to being consumed with guilt over stalling so long on the next episode. I speak at MS, arrive home the 8th of June, leave almost immediately for the first beach week my fam and I have had in five years, *then* I get back home. I swear on my honor as a — nevermind — I swear I will record episode as soon as that beach week ends.
        Seriously? Your interest really helps me, so thank you! — Hill

Leave a Reply

AWSOM Powered