Leave Code Folding To The Reader

Jeff Atwood says that code folding gets overused, and abused. I do use code folding, especially when I am reading someone else’s code. I typically fold by indentation, it gives me a nice overview of the file and its artefacts. I can choose to open a fold, optionally recursive, and focus only on that part.

By usage I believe that code folding is primarily for reading the code, not for writing it. The programmer writing the code should not worry about which parts of the code should fold and which should not. Leave it to the reader. It is not a function of the data, it is a function of the view. So I prefer not to pollute the code with folding directives and such. Folding has not helped me in organization of the code either.

If there is a lot of boilerplate code, I would prefer that it is in fact NOT folded exclusively. It can lead to a good starting point for refactoring the code. It can be valuable if it is assisted with multiple, handy ways of navigating the code.

Of course these are my preferences, and that is how it should be. Editors should allow programmers to use their own way of folding code and viewing it. If folding gets enforced, it sure is going to irk some programmers.

Discussion [Participate or Link]

  1. Multi-Monitor Computer said:

    Hey! I just found this blog and it’s great reading. I will definitely check back regularly!

Say your thought!

If you want to use HTML you can use these tags: <a>, <em>, <strong>, <abbr>, <code>, <blockquote>. Closing the tags will be appreciated as this site uses valid XHTML.



Abhijit Nadgouda
iface Consulting
+91 9819820312
My bookmarks


This is the weblog of Abhijit Nadgouda where he writes down his thoughts on software development and related topics. You are invited to subscribe to the feed to stay updated or check out more subscription options. Or you can choose to browse by one of the topics.