BIGREDSWITCH Push it. You know you want to.

Folding

As editors have added code folding, I’ve generally yawned and ignored it, even when my editor, the best editor in the world, VIM, added it.  I’ve never really reasoned with myself why; it was just an immediate dislike of it. Of course, someone, Jeff Atwood, eventually posted that they hate it too and why. And I thought, yep, I knew that all along.

But, interestingly enough, Atwood was responsible for changing my mind on it. In his and Joel’s podcast (Stack Overflow #15), he said one of those sentences that light up a bulb in your head: something about comparing folding with partial classes (which I’ve never heard of before).  Immediately, I thought about something that bugs me — that’s boilerplate code which clutters up your classes.  For example, javabean methods.  Everytime I have to scroll across a page or two or three of these, it chafes me.  What made the connection with me was that in a previous bout of bitterness, I tried to use inheritence and other tricks to get rid of these methods.  It doesn’t work.  And I’m pretty stubborn and tried some pretty weird things including using a script to stitch classes together.  Yep, partial classes.

So, the short of it is that I use folding now to get rid of javabean methods; and it works well:


  SomeType beanA;
  SomeType beanB;
  SomeType beanC;
  SomeType beanD;
  SomeType beanE;
  SomeType beanF;
  SomeType beanG;
+-- 51 lines: javabean methods -----------------------------------------

  public void someRealMethod()
  {
    // do something real
  }

But, my rules for folding are pretty strict though: that it hides no information and that I would never ever want to edit these methods. Javabean methods fit this definition nicely, so do injection methods; imports do not.


No Comments Yet


There are no comments yet. You could be the first!

Leave a Comment

svndiff Acquisition and coupons