Justin du Coeur (jducoeur) wrote,
Justin du Coeur

Okay, that may qualify as too clever

There I was, coding along, and realized that this clause -- to unsubscribe from someone's presence when they change their IM handle -- also needs to be over there, for the case where they simply delete their IM handle. I copy the code from place A to B, think about it a minute, slap myself mentally, and decide that I should be extracting a method instead.

So I go to code A, invoke Eclipse's "Extract Method", and *poof*, I have a new method. I go over to B, to replace my copied code with a method call...

... and it's already been done for me.

On the one hand, that's exactly what I wanted. OTOH, it's kind of spooky. It hadn't even occurred to me that Extract Method would go looking for duplicate code and refactor that as well. It's probably usually correct, but managed to hit a button I wasn't even aware of -- the "Waitaminnit, that's *my* code! Don't screw with it!" response was quite visceral...
Tags: programming

  • Bagels

    On a lighter note: while I don't entirely want it to be "discovered", the good stuff should be publicized. While Boston isn't New York, we do…

  • TRoOB: Wandering Star

    I always like to save the best for last -- piling a couple of pieces of pepperoni up on the last bite of pizza, and like that. And so I'll wrap up…

  • Review: Person of Interest

    We finally got to the last episode of Person of Interest the other day, so it's time for an overall review of the series. tl;dr: Person of…

  • Post a new comment


    Anonymous comments are disabled in this journal

    default userpic

    Your reply will be screened

    Your IP address will be recorded