If you are a C# Developer, for sure at some time you were part of the following conversation
Regions YES / Regions NO
There are plenty of different opinions on this (check references). If you need to group some parts of your code using regions, you maybe have a “big class”, so probably it’s time for some refactoring.
However, it’s also true that using region may improve the way we read code. There are some scenarios where big classes are required and regions make sense to have a better understanding of the code.
Back in the old days, we face some other projects like CodeMap which are basically focusing the same topic: help a developer to read large pieces of code. We don’t have CodeMap anymore today, it’s evolved to SuperCharger (which I may say, I never use it).
So, I think is a personal choice to use or not use regions. If your goal is to read code and the use of regions helps you, go for it. If you don´t like to use regions, don’t use them :D.
And this is mostly for C# code, but if we switch to XAML, this is a complete different story. Edit XAML code in text mode, is a pain. It’s one of the worst developer experiences ever. And if you think about this, using regions in XAML seems to be a good idea. XAML files are usually large, so regions make sense.
Today I find an extension which add this feature to Visual Studio:
XAML Regions (link)
It’s very easy to use. However after reading a while I find that the use of regions on XAML was implemented in Visual Studio since Visual Studio 2015 (what!?). The format to define regions in XAML is similar to this one:
<!--#region Region Name --> XAML code <!--#endregion-->
Using only 2 lines of code I can switch from this ugly view :
To this much more easier to read view:
My new learning of the day !
Greetings @ Toronto (-42)