Want to read Slashdot from your mobile device? Point it at m.slashdot.org and keep reading!

 



Forgot your password?
typodupeerror
×
Programming IT Technology

The P.G. Wodehouse Method of Refactoring 133

covertbadger notes a developer's blog entry on a novel way of judging progress in refactoring code. "Software quality tools can never completely replace the gut instinct of a developer — you might have massive test coverage, but that won't help with subjective measures such as code smells. With Wodehouse-style refactoring, we can now easily keep track of which code we are happy with, and which code we remain deeply suspicious of."
This discussion has been archived. No new comments can be posted.

The P.G. Wodehouse Method of Refactoring

Comments Filter:
  • by Cecil ( 37810 ) on Sunday March 23, 2008 @04:16AM (#22834898) Homepage
    Code that was written while drunk, high, or half-asleep I will be deeply suspicious of, and probably needs to be refactored immediately. Anything else probably needs refactoring as well, but less urgently.
  • by plover ( 150551 ) * on Sunday March 23, 2008 @04:24AM (#22834912) Homepage Journal
    I hate the e.e. cummings [wikipedia.org] method of refactoring, which is to run all your code through a lower-case filter. Never seems to help very much.
  • I prefer the Raymond Chandler method - if you're having a problem with a section of code, have a man come through the door holding a gun in his hand.
  • by johannesg ( 664142 ) on Sunday March 23, 2008 @04:59AM (#22835038)
    I have an even better idea: instead of printing the code on paper, maybe we could represent it by making corresponding holes in little cards. The cards you could hang in front of the window. As the classes get simpler, the holes can get bigger (because less total space is needed) and they get spread around more easily, so more and more light filters through. This way we can emulate the "sun rising on the project", "light at the end of the tunnel" feeling we all love so dearly.

    Need a status update? Just look into the room - if you can see sunlight, the work is done!

  • by S3D ( 745318 ) on Sunday March 23, 2008 @05:41AM (#22835144)
    My code is not ugly. It's battle-scarred
  • by martin-boundary ( 547041 ) on Sunday March 23, 2008 @06:27AM (#22835256)
    How about the Joel Spolsky method of refactoring [joelonsoftware.com]?

    10 Never throw old code away.

    20 If code is broken, GOTO 10.

  • by IainMH ( 176964 ) on Sunday March 23, 2008 @07:03AM (#22835324)
    Talk about decoupled classes..

    What ho.
  • by ByteGuerrilla ( 918383 ) * on Sunday March 23, 2008 @09:18AM (#22835846)
    It's suspicious if you're reading it and you don't realise it's your code because you keep thinking "What the hell is this guy doing?"
  • by gbjbaanb ( 229885 ) on Sunday March 23, 2008 @11:32AM (#22836612)
    I say Jeeves, cancel my engagements for the morning, Aunt Agatha has decided that I must refactor my code so the Drones Club annual 'ship without testing' party will have to wait.

    Adversity strikes when one least welcomes it Sir.

    She claims my code 'smells'. I'll have her know my code smells as spiffly as a, as a, well, as a whatnot Jeeves.

    Indeed sir.

    Yes, a whatnot. I check my code against the very latest coding practices, and sometimes I even run it through unit tests!

    Admirable qualities in a coder, if I may say, Sir.

    Yes you may Jeeves. Now. to work! beastly testing.

    Sir, perhaps one could use some automated tool or other method of achieving the requisite level of quality desired.

    You know Jeeves, you've hit it right on the head there. I'll get Bernie Smetherington-Smythe to do it, he's such a ghastly bore but, well, when it comes to code review testing, there's no-one that can cut the mustard quite like him. Zip the source up Jeeves, we're to go pay Bernie a visit.

    Certainly Sir, but what if Aunt Agatha finds out?

    Pish Jeeves, pish! The auditors won't be around for months, no-one'll be any the wiser, and I can go to the ship-without-testing party after all. Life just falls into place sometimes doesn't it Jeeves? After all, What could go wrong?

    Yes Sir.
  • There's someone at the door, Jeeves.

    Very good, sir. Mr. Fink-Nottle, sir.

    What ho, Gussie.

    Oh, Bertie, thank heavens you're here! Someone is appropriating the prose style of the greatest author the English language has ever produced, and doing it in the most dreadful manner! He's even capitalizing the word "sir", and having Jeeves make interrogatory rather than simple declarative statements!

    Sorry, Gussie, he did a simple what?

    Oh Bertie, you ass, Jeeves would never actually question you! He would never say, "Certainly Sir, but what if Aunt Agatha finds out?" because that's a flat out question! Besides, he certainly wouldn't refer to your relative as "Aunt Agatha"! He might say, "Certainly Sir, but I might draw attention to the fact that Mrs. Gregson would take a dim view of such an approach." Bertie, you have to do something!

    All well and good, Gussie old thing, but what am I to do? The hands of the Woosters are tied, as it were.

    Not you, you fathead. We want Jeeves for this sort of thing!

    Ah, of course. Jeeves?

    Yo, Mr. B, what up?

    Jeeves, if you could forego the anachronistic and inappropriate argot for the moment, we have a problem, or rather a sort of quandry which requires your attention.

    Word. I talk my talk, yo.

    Sharpen your wits, Jeeves, for this is unlike any you have faced before, and I fear that even you may not be up to the task.

    De nada, boss. I got yer solution right here.

    Jeeves? Do I hear correctly? We've not yet set the problem before you, and you have an answer for us?

    Damn, bitch, didn't I just say that? Can't I hear my own self talking? Sh*t, I know what the problem is and I got the answer. It's self-referential code, dude. The problem is the solution, and vice versa. Get the code to recognize it's own faults, and set it to modify itself.

    And we would then end up with...?

    Undying prose, sir.

    Yes, Jeeves. How appropriate.

    With sincerest apologies to the Master, P.G. Wodehouse, whose writings gave me so much pleasure over the years, until I tried to write novels myself. Then they made me want to kill myself for my inadequacies as a writer.

New York... when civilization falls apart, remember, we were way ahead of you. - David Letterman

Working...