Tuesday, August 5, 2008

To Region or Not To Region, that is the question

In the .net blogging world, it seems that many folks are debating over Jeff Atwoods post on his disdain of regions (see here). My initial reaction was that I agree with Jeff Atwood on many of his points, but I don't agree with his conclusion. I personally use regions for one simple point: To allow me to focus on my current problem at hand.

Jeff has outlined 4 of his problems with regions:
1. Folding directives are glorified comments.
2. Folding is used to sweep code under the rug.
3. Folding is used to mask excessive length.
4. Folding can hide deficiencies in your editor.

I have seen these abuses in both close and open code. This sort of abuse needs to be corrected on a team level, but either the senior or lead developers of said team. If you have renegade programmers using regions as comment fields, you either need to instruct them in the proper fashion of comments, or "get them off the bus".

Personally, I tend to enjoy the region feature of Visual Studio as it allows me to almost work in Visual Studio as productive as I was with Visual Age for Java. One of the nice features of the old version of visual studio is that it forced you to work on a class on a 'method by method' approach. Granted, this can be destroyed if you have a renegate team-member(s) that use them for comments; but this can be corrected behavior. BTW, a wonderful free add-on to Visual Studio to allow you to standardize on the deployment approach to regions is Regionate.

No comments: