Hacker News new | ask | show | jobs
by walking 3783 days ago
From sibling post: > when dealing with those annoying UBER-Forms that tend to happen when dealing with legacy WinForms code :)

This is similar to my experience.

I use regions pretty often when I'm refactoring overgrown legacy code, especially older MVC apps (where the controllers get insane)

Basically what you said, but reversed. I use regions as a first step to regaining some kind of order, then continue to pull things apart into more properly factored classes, methods, etc. It helps me mentally map things out. Of course there're a bunch of ways you could do that, but Visual Studio has good support for folding regions, so I prefer it.

That folding is the second reason I'll use them sometimes. If I have a really awkward part of code that I'd like to fold for whatever reason, I'll occasionally use them if I think it'll make things more readable.

I agree with the idea, though. Every time I use a region I have to stop and think "am I just hiding bad design?"

1 comments

>older MVC apps (where the controllers get insane).

Oh dear lord the MVC madness I've seen... thousand yard stare

I hear you. Seven year old MVC forms with five pages of inputs, backed up to a single forty column table via Entity Framework, and a controller with another five pages of arcane conditionals for binding and validations :|
Please stop, dear god the Entity Framework as well! This horror will keep me up all night now.. :/