My view on regions is mixed. I will say, I do usually sense a code smell when I see a region when I first get into a code base. Mostly because I've lived the nightmare of diving into a region and seeing another region inside that region, and then even regions inside single functions. When I see that then they really get to me as it's just trying to hide the fact that you need to rewrite this code.
I've also seen regions used in places that I'm fine with. An example being a RESTFUL API. I have seen regions used to keep GET requests separate from POST requests in a controller with the controller being well written and skinny. I'm fine with them being used in situations like that.
So like a lot things: use them appropriately. Don't use them to try to hide your badly designed code, and please don't start using nested regions inside a single function call.
My view on regions is mixed. I will say, I do usually sense a code smell when I see a region when I first get into a code base. Mostly because I've lived the nightmare of diving into a region and seeing another region inside that region, and then even regions inside single functions. When I see that then they really get to me as it's just trying to hide the fact that you need to rewrite this code.
I've also seen regions used in places that I'm fine with. An example being a RESTFUL API. I have seen regions used to keep GET requests separate from POST requests in a controller with the controller being well written and skinny. I'm fine with them being used in situations like that.
So like a lot things: use them appropriately. Don't use them to try to hide your badly designed code, and please don't start using nested regions inside a single function call.
Have you ever seen a region nested in a region? That would probably make me cry...
I sadly have. I definitely cried.
To make it worse: I have seen a nested regions inside a constructor before. I am still having nightmares over that...
Oy, I didn't even consider that as a possibility. It hurts to even read it