Hiding code is actually quite useful - its not meant to obscure code that doesn't belong, as you imply.
Say for instance, I'm working on two methods that are expansive, but i'm trying to debug a small part of those methods. To make watching breakpoints and tracking flow easy I hide all but the necessary parts of the code.
I use regions in pretty much the same way - once I have a certain region of functionality locked down and tested, I hide it so I can focus on the part that's still being developed / tested.
My point is: If your class/code/file is so big that you need to hide code to be able to easily navigate (or worse, understand) it, you're doing something wrong.
I understand this is a religious argument of the code world and you're likely to disagree with me. I'm fine with that.
You are missing the point. Lots of large applications I work on maintaining have large awful methods. This feature is excellent in these cases.
You could argue that I should re-factor the whole thing to avoid this issue, but certain design decisions made by someone else make this a huge change, and in the world of risk adverse enterprise applications that is not going to happen.
Can you not start writing tests against those monster methods so that you've got a refactoring safety net?
I totally agree on being practical and not refactoring methods that work correctly. But if you find yourself in the monster methods making changes quite often, it seems irresponsible to not refactor and leave the camp ground cleaner for the next time you or someone else comes through it.
Its a big ball of dependencies with no chance to mock due to someone deciding on being "clever". Its up there with being untestable.
Generally I agree. If possible clean it up, but quite often its a small one line change, which needs to be fixed ASAP, so there is little chance to refactor.
> If your class/code/file is so big that you need to hide code to be able to easily navigate (or worse, understand) it, you're doing something wrong.
Wrong. If your class/code/file is so big that you need to hide code to be able to easily navigate (or worse, understand) it, the author was doing something wrong.
To be honest, its like a matter of OCD to me - for instance, I like keeping my desktop completely free of icons (even though I don't need to).
In a similar way, I like only looking at the code that's relevant - if the method I'm working on is larger than a single screen (which happens with comments and such included) I like collapsing parts I don't care about. I don't, strictly speaking, need to in order to work effectively but I like to - as you said, more of a religious argument than a quantifiable one.
Say for instance, I'm working on two methods that are expansive, but i'm trying to debug a small part of those methods. To make watching breakpoints and tracking flow easy I hide all but the necessary parts of the code.
I use regions in pretty much the same way - once I have a certain region of functionality locked down and tested, I hide it so I can focus on the part that's still being developed / tested.