The first time I saw the feature called CodeRegions was back in the 90s, the tool was  the HotDog Editor, it allows you to collapse HTML tag elements.  Now, with VS.Net we have the same feature for C# and VB.Net code. I liked it.

The first idea that comes to every developer is: "wow !!, we are going to use REGIONS to indicate the different Code Areas, like: PROPERTIES, METHODS, IMPL_INTERFACES, and so on.." so we don't need to scroll to see a specific piece of code.

But what happens when people abuse of regions? I've seen different mistakes:

  • Use regions to delimit just one line of code (and sometimes none !!)
  • Use regions to delimit functionality,  instead of Refactor it with the ExtractClass Pattern
  • Regions get unmantained as the code changes, so you get the WrongComments AntiPattern.
  • Simple classes of few lines of code becomes complex code because the regions

Another important drawback of the regions is the fact it's a VS only feature. I only write code with VS, but I use to read code with different tools and viewers that don't understand regions, like SourceInsight, HTMLConverters, or a simple copy-paste in any document.

Finally, I have decided to NotUseRegions, instead I always try to refactor the code until it transmit intention while compiles. MicroDesign. 

Clean Code That Works does not need Regions.