News for hackers. Stuff that matters.
Re:Windows CoreAudio API in C# by kenjackson on Thursday February 04, 2016 @06:01PM (#11037967)
I think regions are super useful. Even within the context of a class, I create regions for various types of code, e.g., constructors, private fields, etc...

I'm not sure how regions change how you create your class hierarchies and such. One of the first things I do when I inherit a project, is I add regions to it. I'm not changing the class hierarchies, but I am making it a lot easier to navigate within Visual Studio.

Re:Windows CoreAudio API in C# by Someone1234 on Thursday February 04, 2016 @06:12PM (#11038034)
I don't see how hiding large chunks of code behind a drop-down is making it "easier to navigate in Visual Studio." If anything it is now much harder.

Plus you're now burying how long your class is and the individual methods within. So a class or method that would otherwise be inappropriately long now looks a reasonable length.

If you feel like the code is so long that it needs regions, then refactor the code, don't hide the mess under the bed.

Re:Windows CoreAudio API in C# by walking on Thursday February 04, 2016 @09:19PM (#11038966)
I can't speak for the gp, but they were talking about inheriting a project/legacy code.

If I end up needing to go through legacy code, and there are a lot of gnarly, long methods/blocks, I'll usually add comments and regions to it as I go along. I'll use comments if I just want to note something, and a region if I want to note something about a region of code. It's my rough map. Being able to tell Visual Studio to arbitrarily collapse an area is handy for sketching it. The long term goal is to refactor, but it's handy as a way to quickly outline things.

Re:Windows CoreAudio API in C# by kenjackson on Thursday February 04, 2016 @11:53PM (#11039538)
Point me to some of your code and I bet it would benefit from well placed regions.
Re:Windows CoreAudio API in C# by dpark on Thursday February 04, 2016 @08:04PM (#11038646)
Ugh. Every time I inherit code that someone has peppered with regions, I delete then. It's a bunch of extra noise if you expand all regions, and if they're collapsed it's harder to see the overall structure of the code, and some functionality (specifically undo/redo, but others also) gets gimpy when collapsed regions are involved, making it hard to see what is changing.

I find regions to be useful 1% of the time, simply pointless 10% of the time, and hiding crappy code the other 89% of the time. When I open up code and see a bunch of regions, I immediately assume that the file contains way too much unrelated functionality and that the code is poorly written. This assumption is very rarely wrong.

Re:Windows CoreAudio API in C# by jameshart on Thursday February 04, 2016 @10:03PM (#11039121)

   ca82a6d - kenjackson - 10 files changed, 34 insertions: "Added some regions"
   085bb3b - dpark - 10 files changed, 34 deletions: "Removed regions"
   a11bef0 - kenjackson - 10 files changed, 34 insertions: "Added some regions"
   2432f8e - dpark - 10 files changed, 34 deletions: "Removed regions"
   cbe6306 - kenjackson - 10 files changed, 34 insertions: "Added some regions"
   e7e1bef - dpark - 10 files changed, 34 deletions: "Removed regions"
   ....
Re:Windows CoreAudio API in C# by sverrirs on Friday February 05, 2016 @03:57AM (#11040355)
gold, pure gold :D
Re:Windows CoreAudio API in C# by kenjackson on Thursday February 04, 2016 @11:49PM (#11039530)
In fairness though that assumption is almost always true regardless.