Skip to main content
grammar
Source Link
eebbesen
  • 137
  • 1
  • 8

In C# code it allows the #regionuse of #region/#endregion#endregion keywords to mademake areas of code collapsible in the editor. Whenever I am doingdo this though I finddo it is to hide large chunks of code that could probably be refactored into other classes or methods. For example I have seen methods that contain 500 lines of code with 3 or 4 regions just to make it manageable.

So is judicious use of regions a sign of trouble? It seems to be so to me.

In C# code it allows the #region/#endregion keywords to made areas of code collapsible in the editor. Whenever I am doing this though I find it is to hide large chunks of code that could probably be refactored into other classes or methods. For example I have seen methods that contain 500 lines of code with 3 or 4 regions just to make it manageable.

So is judicious use of regions a sign of trouble? It seems to be to me.

C# allows the use of #region/#endregion keywords to make areas of code collapsible in the editor. Whenever I do this though I do it to hide large chunks of code that could probably be refactored into other classes or methods. For example I have seen methods that contain 500 lines of code with 3 or 4 regions just to make it manageable.

So is judicious use of regions a sign of trouble? It seems to be so to me.

Question Protected by gnat
Tweeted twitter.com/#!/StackProgrammer/status/563756930536325120
Post Made Community Wiki by Loren Pechtel
Source Link
Craig
  • 4.3k
  • 3
  • 23
  • 21

Are #regions an antipattern or code smell?

In C# code it allows the #region/#endregion keywords to made areas of code collapsible in the editor. Whenever I am doing this though I find it is to hide large chunks of code that could probably be refactored into other classes or methods. For example I have seen methods that contain 500 lines of code with 3 or 4 regions just to make it manageable.

So is judicious use of regions a sign of trouble? It seems to be to me.