By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,730 Members | 1,500 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,730 IT Pros & Developers. It's quick & easy.

Survey: Regions

P: n/a
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?

__________________________________________________ ____
__________________________________________________ ____
__________________________________________________ ____
__________________________________________________ ____
__________________________________________________ ____
__________________________________________________ ____
__________________________________________________ ____
__________________________________________________ ____
Nov 16 '05 #1
Share this Question
Share on Google+
6 Replies


P: n/a

"C# Learner" <cs****@learner.here> wrote in message
news:OW**************@tk2msftngp13.phx.gbl...
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.
Nov 16 '05 #2

P: n/a
Daniel O'Connell [C# MVP] <onyxkirx@--NOSPAM--comcast.net> wrote:
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 - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 16 '05 #3

P: n/a

"Jon Skeet [C# MVP]" <sk***@pobox.com> wrote in message
news:MP************************@msnews.microsoft.c om...
Daniel O'Connell [C# MVP] <onyxkirx@--NOSPAM--comcast.net> wrote:
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.


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.
--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too

Nov 16 '05 #4

P: n/a
C# Learner wrote:
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

--
Get LLBLGen Pro, the new O/R mapper for .NET: http://www.llblgen.com
My .NET Blog: http://weblogs.asp.net/fbouma
Microsoft C# MVP
Nov 16 '05 #5

P: n/a
Frans Bouma [C# MVP] <pe******************@xs4all.nl> wrote:
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 :)

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 16 '05 #6

P: n/a
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.
Nov 16 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.