Progressive Development

Zany Adventures in Software Engineering with Maven and Motley

Motley says: "I don't have time to Refactor - I need to get it right the first time"

Motley says: "I don't have time to Refactor - I need to get it right the first time"

  • Comments 2
 

Summary

 

Motley: Refactoring takes too much time - I have to ship you know!

 

Maven: Refactoring leads to much more maintainable code, and if you have tests in place, the return on investment far outweighs the cost.

______________________________

 

[Context: Motley has just embarked on his first adventures with TDD, but Maven wants to check-in to ensure Motley really understands the process]

 

Maven: So how are things going with TDD, Motley?

 

Motley: I've only been at this for a couple of hours - why are you bugging me already?

 

Maven: It's good to start off on the right path. Just want to make sure you understand the TDD process.

 

Motley: Yeah, yeah, yeah. Write a failing test. Write code to pass it. Move on to the next requirement.

 

Maven: Whoa there, Nelly! You forgot one of the most important steps - refactoring.

 

Motley: Not really sure what you mean by that. If I have syntax errors I fix them. Duh.

 

Maven: Refactoring is all about improving the design of your code without changing any existing functionality. You mentioned previously that one of your values is writing great software. Well, refactoring is not just about writing it great the first time, it's about being realistic with yourself that you won't get it right the first time. You make the necessary changes to prevent it from starting just OK and turning into a big turd later as you maintain it. Obviously it takes more time than just writing the code once, but the pay-off down the road is huge.

 

Motley: You've been sniffing too much glue, Maven. I barely have enough time to write my code once let alone keep redoing it over and over. I have to ship. If I don't ship, the business suffers, and most important, I get fired, and I suffer.

 

Maven: What about when someone has to maintain that code moving forward? Do you want to make it difficult for them? How much do you think that costs the business?

 

Motley: Like everything in life, there is a trade-off. I have to do my best given that one shot is all I get. I vote ship and deal with maintenance issues later.

 

Maven: That's what has gotten us into all this trouble with our legacy code! How do you like fixing bugs in all that old stuff?

 

Motley: Well… it sucks. Our legacy code is a "turd" - as you so eloquently put it.

 

Maven: Exactly. We need to make it easier for the next person to maintain. Refactoring is a way to get us there. Write your code, improve it, and then move forward with the next requirement. It's actually quite natural once you get in the rhythm.

 

Motley: But I'm afraid that once I have it working that if I make changes I'll break something.

 

Maven: Ah, but you're doing TDD, right? That means you have tests in place so that if you do happen to break something you know about it right away. It's quite beautiful, really. Give it a shot and I'll check in with you later.

 

Motley: Why do I keep letting you do this to me? Fine, I'll try it. But if I'm late on my deliverables, it's your paycheck. Deal?

 

Maven: I'm so confident that you're going to rock that yeah, I'll take that bet.

______________________________

 

Maven's Pointer: Many times the primary reason that developers are afraid to refactor isn't because they don't have the time, but because they don't have the confidence to make a change without breaking existing behavior. Having unit tests in place increases that confidence and makes refactoring easier and fun. Avoid refactoring without first having tests in place!

 

Maven's Resources:  Refactoring: Improving the Design of Existing Code, by Martin Fowler et al, Addison-Wesley Professional, ISBN: 0201485672, 1999.

  • A helpful refactoring is renaming Motley and Maven. Take for example Alice and Bob who are a dubious pair of individuals, alledgedly I hear rumours about what they are up to but never see their communications to confirm the rumours. I often ponder about Alice, Bob and others such as Mallory, doing so is easy because their names are so distinct and their Initials provide a clue to their role in my thoughts. Reading the adventures of M & M constantly makes me think is M the one I like or is it the other M, thinking of synonyms of their names never helps.

  • Thanks for the comments. I put a lot of thought in to the names and got much feedback, and Maven and Motley seemed perfect. Although they both start with "M" (which I agree, can be confusing at times), the key is the definition of the terms.

    MAVEN: A maven (also mavin or mayvin) is an expert in a particular field, usually one who is self-appointed and who seeks to pass his knowledge on to others.

    (http://en.wikipedia.org/wiki/Maven)

    -- I thought this was a perfect definition for the character.

    MOTLEY: assorted: consisting of a haphazard assortment of different kinds (even to the point of incongruity); exhibiting great diversity of elements; heterogeneous

    -- Although not quite as perfect as "Maven", it does reflect Motley's take on development - a haphazard array of techniques that are not really effective.

    I also liked both names as they are somewhat unique and more easily remembered. I really like "Mallory" and may fold that in with the "M" theme if it doesn't make it more confusing :-).

    I really appreciate the feedback. I think I'll stick with Maven and Motley for a while unless I get more complaints.

    Keep the feedback coming!

Page 1 of 1 (2 items)
Leave a Comment
  • Please add 3 and 1 and type the answer here:
  • Post