Survey: Regions

  • Thread starter Thread starter C# Learner
  • Start date Start date
C

C# Learner

1) How often do you put regions into your code?

a) very often
b) occasionally
c) infrequently
d) never

2) If you didn't answer (d), what do you use regions for?

a) hiding ugly code
b) separating code into logical, collapsible blocks
c) both
d) other:
___________________________________________________

3) If you did answer (d), why don't you use them?

______________________________________________________
______________________________________________________
______________________________________________________
______________________________________________________
______________________________________________________
______________________________________________________
______________________________________________________
______________________________________________________
 
C# Learner said:
1) How often do you put regions into your code? d

2) If you didn't answer (d), what do you use regions for? N/A

3) If you did answer (d), why don't you use them?

It annoys me to have to use the mouse to edit a piece of code; I also don't
care to try to remember more key combonations(outside of the debugging keys,
edit keys, ctrl-space and ctrl-k ctrl-f to format code, I can't remember
combonations for the life of me). So, every region in code slows me down.

Also, due to the way I write code, there is often little easy use for
regions. Outside of constructors, I group by functionality instead of by
accessibility, much of the time. It isn't uncommon to see a private field
near a property, or a public method, a protected Impl\Core method, and
several protected or private helper methods in the same area when all of
those private methods relate only to the public method. As such, I would be
making regions for every public method in some situations..which is silly,
IMHO.
 
Daniel O'Connell said:
Also, due to the way I write code, there is often little easy use for
regions. Outside of constructors, I group by functionality instead of by
accessibility, much of the time. It isn't uncommon to see a private field
near a property, or a public method, a protected Impl\Core method, and
several protected or private helper methods in the same area when all of
those private methods relate only to the public method. As such, I would be
making regions for every public method in some situations..which is silly,
IMHO.

I write code in the same way - but that's a reason *for* using regions,
IMO.

For instance, if I write one public method and 5 private helper
methods, I can lump all of that together in one region, and I'll only
see that code if I'm actually interested in that public method.
 
Jon Skeet said:
I write code in the same way - but that's a reason *for* using regions,
IMO.

For instance, if I write one public method and 5 private helper
methods, I can lump all of that together in one region, and I'll only
see that code if I'm actually interested in that public method.

You've got a point, I should have related it to the first reason, ;). It
would mean I'd have to take my hands off the keyboard even more often. I
guess I really should learn the shortcuts to expand and collapse a region,
that would make my arguments pretty moot I suppose.
 
C# Learner said:
1) How often do you put regions into your code?

a) very often
b) occasionally
c) infrequently
d) never
a)

2) If you didn't answer (d), what do you use regions for?

a) hiding ugly code
b) separating code into logical, collapsible blocks
c) both
d) other:

C)

Although I agree with Daniel that there should be a keyboard shortcut to
expand/collaps a region, I still find them very useful. I even wrote macros
to create member region's property regions or a region with the name you
specify in a dialog. I hide winforms control definitions with a region too
(hence 'c' instead of b :)) however the winforms designer is too dumb to
understand them and almost always dumps new controls in the wrong region. :(

I don't put interface specific implementations in a separate region like the
interface stubber does, because IMHO that would create too much region clutter

FB
 
Frans Bouma said:
Although I agree with Daniel that there should be a keyboard shortcut to
expand/collaps a region

There is - Ctrl-M Ctrl-M. That actually collapses or expands any
outline, not just the current region, but it's still better than
nothing :)
 
C# Learner wrote:

<snip>

Personally, I never put regions into my code (although I leave in the
ones added by MS VS.NET to hide the ugly "designer generated code") with
one exception -- like Frans, I hide form _control_ declarations in a region.

The reasons I don't use regions are that, as Daniel said, they make
browsing code a bit more effort. However, I wanted to ask anyway to get
people's input as I'm thinking about using them a bit more.

Actually, an idea just sprung to mind -- I suppose they would come in
handy when making a class which uses the Singleton pattern. They could
be used to hide the static member and the interface which exposes this
member.

Anyway, thanks for your replies.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top