Is Code Folding that bad...?

I am a huge fan of Jeff Atwood and Coding Horror. I usually like his stuff. But I somehow didn't agree too much to his post where he talks about Code Folding (#region). I mean of course I also agree with a few things that he says, so let me put them down here:

 

Things that I do not agree with:

  • "Folding directives are Glorified Comments": We don't fold code to accommodate the editor, we do it to accommodate ourselves. Code folding is more like indexing. I index my code so I know exactly where to go when I am reading it. It is like creating folders for files. I go to a specific file and know I want to check an event handler for example. so I open the Event Handlers Region and reach the exact event handler I require. Besides, I agree that traditional comments are better and more descriptive, but they have a different purpose than #region.
  • "Folding is used to sweep code under the rug": Perspective, perspective... I would call it, "neatly arranging it in a nice closet and closing the doors instead of keeping everything out on an open shelf".
  • "Folding is used to mask excessive length": Nuclear power could cause a nuclear holocaust or it could assist in the creation of an alternative source of power to keep cars running, Air conditioner fans turning and perhaps to achieve warp speed, who knows. Writing short and clean code is a matter of personal discipline just like checking in code into your repository before leaving for home. Even when there were no regions, people did write excessively long and convoluted source code. And #regions wouldn't hide code during inspection or code reviews. Everything would be reviewed when it is reviewed; folded or otherwise. In fact, it might make reviews more convenient. The reviewer unfolds everything and then systematically folds everything that has been reviewed.
  • "Folding can hide deficiencies in your editor": This "scutwork" really helps good programmers to read code. And as I have read somewhere, good programmers read more code than they write. Code folding enables that.

Things that I agree with:

  • "The editor should automatically offer to fold up these common structural blocks to you"
  • "#region is criminally overused"
  • "Code should be written that doesn't need folding to be readable, clear and concise"

 

So Jeff, I love your writing, no questions... And you have a right to your opinions and to what you publish... But be gentle at times man...!

Published Friday, July 11, 2008 8:29 PM by Nilotpal Das

Comments

Friday, February 18, 2011 11:15 AM by Kate Karver

# re: Is Code Folding that bad...?

It was rather interesting for me to read that article. Thank author for it. I like such topics and everything connected to them. I definitely want to read more soon.    

Kate  Karver  

<a href="indianescortmodels.com/">Central London Indian escorts</a>

Saturday, February 26, 2011 11:51 PM by Mary Meetington

# re: Is Code Folding that bad...?

It is extremely interesting for me to read the post. Thanks for it. I like such topics and anything connected to this matter. I definitely want to read more soon.    

Mary  Meetington    

<a href="www.latinescortlondon.com/">London escort brazilian</a>

Saturday, April 16, 2011 7:34 PM by Sara Pingtown

# re: Is Code Folding that bad...?

It is extremely interesting for me to read that post. Thanx for it. I like such topics and anything that is connected to this matter. I definitely want to read more soon.            

Sara  Pingtown          

<a href="www.baccaratgirls.com/">best escort</a>

Leave a Comment

(required) 
(required) 
(optional)
(required)