Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Regions aren't a .Net Framework feature, they're a language feature.

There's absolutely no reason they should be in C# and encourage bad coding practices (like overly long .cs files). Even if you need all your code in a single class, you can shard that class across several .cs files to make organisation and maintainability easier.

Regions are just a crutch people use to allow them to create 10K+ line .cs files that will eventually become a maintainability nightmare (as well as making merges/check-ins/finding things more annoying in general).

Only region I'll use is the built DEBUG one and I only use that to create:

     private bool IsDebug()
     {
     #if DEBUG
       return true;
     #else
       return false;
     #endif
     }
Stackoverflow answer for why regions are bad: http://softwareengineering.stackexchange.com/questions/53086...


I agree about regions, but `#if` et al are preprocessor directives, not regions. They actually influence how your code is compiled.


Well, just because YOU cannot write good code with regions doesn't mean it's a bad feature. It's actually very very useful thing, but as with everything, you have to know when and how to use it.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: