Article 2H6Y3 CodeSOD: The Refactoring

CodeSOD: The Refactoring

by
Remy Porter
from The Daily WTF on (#2H6Y3)

I have certain mantras that I use to guide my programming. They generally revolve around this theme: "Thinking is hard, and I'm not very good at it; every block of code should be simple and obvious, because if it makes me think, I'll probably screw it up and break something." It's a good rule for me, and a good general guideline, but it's a little vague to implement as a policy.

Erika's company wanted to implement this idea as a policy, so they set a limit on how many lines could be in a single method. The thinking was that if each method was short- say, under 100 lines- it would automatically be simple(r), right?

Well, Garret, down the hall, wrote a method that was three hundred lines long. During a code review, he was told to refactor it to simplify the logic and comply with the policy. So he did.

public void Update(){ UpdateSection01(); UpdateSection02(); UpdateSection03();}
release50.png[Advertisement] Release!is a light card game about software and the people who make it. Play with 2-5 people, or up to 10 with two copies - only $9.95 shipped! TheDailyWtf?d=yIl2AUoC8zA1a9HUS4ji58
External Content
Source RSS or Atom Feed
Feed Location http://syndication.thedailywtf.com/TheDailyWtf
Feed Title The Daily WTF
Feed Link http://thedailywtf.com/
Reply 0 comments