Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. The Lounge
  3. Regions: Love or Hate

Regions: Love or Hate

Scheduled Pinned Locked Moved The Lounge
csharpcssvisual-studiocollaborationhelp
93 Posts 63 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Dave Kerr

    I used to love regions, stuck them everywhere in my code. Now I hate them, each member of our team uses them differently. What's the public opinion - are regions good or bad? Would they be better if they were REALLY big in Visual Studio? I find that I'm squinting to find the little buggers, if they were much more obvious I might get lost less...

    V Offline
    V Offline
    vonb
    wrote on last edited by
    #26

    I use them sometimes (Interface related, etc.) but in WPF, as there is much more design than code, it doesn't make many sense.

    1 Reply Last reply
    0
    • D Dave Kerr

      I used to love regions, stuck them everywhere in my code. Now I hate them, each member of our team uses them differently. What's the public opinion - are regions good or bad? Would they be better if they were REALLY big in Visual Studio? I find that I'm squinting to find the little buggers, if they were much more obvious I might get lost less...

      K Offline
      K Offline
      Keith Barrow
      wrote on last edited by
      #27

      Used to like, now dislike: Used to like and used them to tidy up "sections" of classes (e.g. fields, properties, methods) now I've come round to the opinion that is just hides code. Too often they hide incorrect class structure and poor general design. The worst offenders in this case are inside methods where a region is used to hide what should be refactored into private methods in some poorly written god-method. I've seeen them used to hide Data Access stuff in an object model which should have been a whole different architectural layer and entire "classes" within a god-class.

      Sort of a cross between Lawrence of Arabia and Dilbert.[^]
      -Or-
      A Dead ringer for Kate Winslett[^]

      A 1 Reply Last reply
      0
      • OriginalGriffO OriginalGriff

        I wasn't sure until I started using them to group related items in the same file: Fields Properties Constructors Event handlers Public properties Private properties Now I find it reduces the clutter, and lets you see what you are interested in, without being distracted by irrelevancies. So much so that I modified the VS default class (and so forth) files to include them as standard. There is a Tip/Trick about it here: Adding your items to Visual Studio default files[^]

        Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together. Manfred R. Bihy: "Looks as if OP is learning resistant."

        D Offline
        D Offline
        Dave Kerr
        wrote on last edited by
        #28

        Nice, that's a useful tip

        1 Reply Last reply
        0
        • D Dave Kerr

          I used to love regions, stuck them everywhere in my code. Now I hate them, each member of our team uses them differently. What's the public opinion - are regions good or bad? Would they be better if they were REALLY big in Visual Studio? I find that I'm squinting to find the little buggers, if they were much more obvious I might get lost less...

          B Offline
          B Offline
          BillWoodruff
          wrote on last edited by
          #29

          I like them ... used judiciously. best, Bill

          "Is it a fact - or have I dreamt it - that, by means of electricity, the world of matter has become a great nerve, vibrating thousands of miles in a breathless point of time? Rather, the round globe is a vast head, a brain, instinct with intelligence!" - Nathanial Hawthorne, House of the Seven Gables

          1 Reply Last reply
          0
          • D Dave Kerr

            I used to love regions, stuck them everywhere in my code. Now I hate them, each member of our team uses them differently. What's the public opinion - are regions good or bad? Would they be better if they were REALLY big in Visual Studio? I find that I'm squinting to find the little buggers, if they were much more obvious I might get lost less...

            C Offline
            C Offline
            Chris Maunder
            wrote on last edited by
            #30

            Like anything in code their use needs to be part of your coding standards. What I'd like to see is a way to colour the entire background of a region (specifically, green or yellow). I use them like

            #region Public Methods ----------------------------------------------

            and having the entire line highlighted would make them so increidbly valuable as markers. And I know: If your files are short enough you never need something like this... cheers, Chris Maunder The Code Project | Co-founder Microsoft C++ MVP

            T D 2 Replies Last reply
            0
            • D Dave Kerr

              I used to love regions, stuck them everywhere in my code. Now I hate them, each member of our team uses them differently. What's the public opinion - are regions good or bad? Would they be better if they were REALLY big in Visual Studio? I find that I'm squinting to find the little buggers, if they were much more obvious I might get lost less...

              W Offline
              W Offline
              W Balboos GHB
              wrote on last edited by
              #31

              Region is the opiate of the people! Ooops. I read that wrong. Never mind

              "The difference between genius and stupidity is that genius has its limits." - Albert Einstein

              "As far as we know, our computer has never had an undetected error." - Weisert

              "If you are searching for perfection in others, then you seek disappointment. If you are seek perfection in yourself, then you will find failure." - Balboos HaGadol Mar 2010

              D 1 Reply Last reply
              0
              • C Chris Maunder

                Like anything in code their use needs to be part of your coding standards. What I'd like to see is a way to colour the entire background of a region (specifically, green or yellow). I use them like

                #region Public Methods ----------------------------------------------

                and having the entire line highlighted would make them so increidbly valuable as markers. And I know: If your files are short enough you never need something like this... cheers, Chris Maunder The Code Project | Co-founder Microsoft C++ MVP

                T Offline
                T Offline
                Tom Deketelaere
                wrote on last edited by
                #32

                Devexpress has something similar to that. Regions can be colored in a differant colour but not the entire region background unfortunately. There is a line indicating the start and end of the region and the option to have the name of the region both at the start and end. I find that it helps but could still be improved on. By the way something seems to be wrong with your sig. Don't see the line seperating your message and sig and there is html in it. This is what I get:

                And I know: If your files are short enough you never need something like this...

                cheers,
                Chris Maunder

                The Code Project | Co-founder
                Microsoft C++ MVP

                1 Reply Last reply
                0
                • D Dave Kerr

                  I used to love regions, stuck them everywhere in my code. Now I hate them, each member of our team uses them differently. What's the public opinion - are regions good or bad? Would they be better if they were REALLY big in Visual Studio? I find that I'm squinting to find the little buggers, if they were much more obvious I might get lost less...

                  M Offline
                  M Offline
                  Mario Luis
                  wrote on last edited by
                  #33

                  I like them as long as used sensibly. They're also great when working with a section of controls events, I put all the events of a group of controls together and stick them in a region, makes it much easier to read.

                  1 Reply Last reply
                  0
                  • D Dave Kerr

                    I used to love regions, stuck them everywhere in my code. Now I hate them, each member of our team uses them differently. What's the public opinion - are regions good or bad? Would they be better if they were REALLY big in Visual Studio? I find that I'm squinting to find the little buggers, if they were much more obvious I might get lost less...

                    S Offline
                    S Offline
                    S Houghtelin
                    wrote on last edited by
                    #34

                    If regions are being used to hide code then they are being used incorrectly. When someone "hides" something that means they don't want you to see it. Sweeping a mess under the carpet does not eliminate it, now you have a lumpy rug that someone will trip on. I absolutely agree with using them to group related items, I especially likes Griff’s list above. The ability to change the background to have them stand out would be nice.

                    It was broke, so I fixed it.

                    1 Reply Last reply
                    0
                    • D Dave Kerr

                      I used to love regions, stuck them everywhere in my code. Now I hate them, each member of our team uses them differently. What's the public opinion - are regions good or bad? Would they be better if they were REALLY big in Visual Studio? I find that I'm squinting to find the little buggers, if they were much more obvious I might get lost less...

                      N Offline
                      N Offline
                      Nemanja Trifunovic
                      wrote on last edited by
                      #35

                      I use an editor[^] that supports real code folding. [^]. Why would I need "regions"? :-\

                      utf8-cpp

                      1 Reply Last reply
                      0
                      • D Dave Kerr

                        I used to love regions, stuck them everywhere in my code. Now I hate them, each member of our team uses them differently. What's the public opinion - are regions good or bad? Would they be better if they were REALLY big in Visual Studio? I find that I'm squinting to find the little buggers, if they were much more obvious I might get lost less...

                        V Offline
                        V Offline
                        V 0
                        wrote on last edited by
                        #36

                        good use is a bliss, bad use; hell. :)

                        V.

                        S 1 Reply Last reply
                        0
                        • OriginalGriffO OriginalGriff

                          Slacker007 wrote:

                          your team needs to ALL be on the same sheet of music

                          Oh yes! Nothing worse than one idiot individual who insists on K&R bracket format when everyone else has got an IQ bigger than their shoe size moved on to a more readable style.

                          Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together. Manfred R. Bihy: "Looks as if OP is learning resistant."

                          G Offline
                          G Offline
                          GuyThiebaut
                          wrote on last edited by
                          #37

                          I did not know what K&R was so I looked it up - euugh! X| That is a seriously bad way to screw with people's minds!

                          Continuous effort - not strength or intelligence - is the key to unlocking our potential.(Winston Churchill)
                          1 Reply Last reply
                          0
                          • V V 0

                            good use is a bliss, bad use; hell. :)

                            V.

                            S Offline
                            S Offline
                            S Houghtelin
                            wrote on last edited by
                            #38

                            V. wrote:

                            good use is a bliss, bad use; hell

                            Very appropriate description of how to write code in any language old, outdated or new. +5 :thumbsup:

                            It was broke, so I fixed it.

                            1 Reply Last reply
                            0
                            • C Chris Maunder

                              Like anything in code their use needs to be part of your coding standards. What I'd like to see is a way to colour the entire background of a region (specifically, green or yellow). I use them like

                              #region Public Methods ----------------------------------------------

                              and having the entire line highlighted would make them so increidbly valuable as markers. And I know: If your files are short enough you never need something like this... cheers, Chris Maunder The Code Project | Co-founder Microsoft C++ MVP

                              D Offline
                              D Offline
                              Dave Kerr
                              wrote on last edited by
                              #39

                              That's what I was thinking, if they could change the whole background then they might be a bit more visible. I suppose it could be done in VS2010 as WPF plugins can be written to draw in the code editor

                              1 Reply Last reply
                              0
                              • W W Balboos GHB

                                Region is the opiate of the people! Ooops. I read that wrong. Never mind

                                "The difference between genius and stupidity is that genius has its limits." - Albert Einstein

                                "As far as we know, our computer has never had an undetected error." - Weisert

                                "If you are searching for perfection in others, then you seek disappointment. If you are seek perfection in yourself, then you will find failure." - Balboos HaGadol Mar 2010

                                D Offline
                                D Offline
                                Dave Kerr
                                wrote on last edited by
                                #40

                                Just snorted tea all over my desk with that one

                                W 1 Reply Last reply
                                0
                                • D Dave Kerr

                                  Just snorted tea all over my desk with that one

                                  W Offline
                                  W Offline
                                  W Balboos GHB
                                  wrote on last edited by
                                  #41

                                  You should not be surprised to learn that you've just made my day.

                                  "The difference between genius and stupidity is that genius has its limits." - Albert Einstein

                                  "As far as we know, our computer has never had an undetected error." - Weisert

                                  "If you are searching for perfection in others, then you seek disappointment. If you are seek perfection in yourself, then you will find failure." - Balboos HaGadol Mar 2010

                                  1 Reply Last reply
                                  0
                                  • K Keith Barrow

                                    Used to like, now dislike: Used to like and used them to tidy up "sections" of classes (e.g. fields, properties, methods) now I've come round to the opinion that is just hides code. Too often they hide incorrect class structure and poor general design. The worst offenders in this case are inside methods where a region is used to hide what should be refactored into private methods in some poorly written god-method. I've seeen them used to hide Data Access stuff in an object model which should have been a whole different architectural layer and entire "classes" within a god-class.

                                    Sort of a cross between Lawrence of Arabia and Dilbert.[^]
                                    -Or-
                                    A Dead ringer for Kate Winslett[^]

                                    A Offline
                                    A Offline
                                    AspDotNetDev
                                    wrote on last edited by
                                    #42

                                    Keith Barrow wrote:

                                    I've seeen them used to hide Data Access stuff in an object model which should have been a whole different architectural layer and entire "classes" within a god-class.

                                    Guilty.

                                    Martin Fowler wrote:

                                    Any fool can write code that a computer can understand. Good programmers write code that humans can understand.

                                    1 Reply Last reply
                                    0
                                    • OriginalGriffO OriginalGriff

                                      Slacker007 wrote:

                                      your team needs to ALL be on the same sheet of music

                                      Oh yes! Nothing worse than one idiot individual who insists on K&R bracket format when everyone else has got an IQ bigger than their shoe size moved on to a more readable style.

                                      Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together. Manfred R. Bihy: "Looks as if OP is learning resistant."

                                      Q Offline
                                      Q Offline
                                      QuiJohn
                                      wrote on last edited by
                                      #43

                                      OriginalGriff wrote:

                                      Oh yes! Nothing worse than one idiot individual who insists on K&R bracket format when everyone else has got an IQ bigger than their shoe size moved on to a more readable style.

                                      Hey now, a lot of us started C programming with K&R sitting next to our keyboards. Sure, maybe they did it to save on the number of published pages, but it was as natural as breathing. After many years I finally realized it looked like crap though, and forced myself to change ;)

                                      OriginalGriffO 1 Reply Last reply
                                      0
                                      • R realJSOP

                                        I like regions to a point. I think they would be more useful if we could set their background color to something other than the white space color.

                                        ".45 ACP - because shooting twice is just silly" - JSOP, 2010
                                        -----
                                        You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010
                                        -----
                                        "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass." - Dale Earnhardt, 1997

                                        Q Offline
                                        Q Offline
                                        QuiJohn
                                        wrote on last edited by
                                        #44

                                        John Simmons / outlaw programmer wrote:

                                        I think they would be more useful if we could set their background color to something other than the white space color.

                                        That is an outstanding idea. I never, ever use them right now. But color coded regions would make me feel not as bad about those 500 line functions. (They're not my fault! Entirely...)

                                        1 Reply Last reply
                                        0
                                        • Q QuiJohn

                                          OriginalGriff wrote:

                                          Oh yes! Nothing worse than one idiot individual who insists on K&R bracket format when everyone else has got an IQ bigger than their shoe size moved on to a more readable style.

                                          Hey now, a lot of us started C programming with K&R sitting next to our keyboards. Sure, maybe they did it to save on the number of published pages, but it was as natural as breathing. After many years I finally realized it looked like crap though, and forced myself to change ;)

                                          OriginalGriffO Offline
                                          OriginalGriffO Offline
                                          OriginalGriff
                                          wrote on last edited by
                                          #45

                                          I did too - after a Instruction Set one week course - but I hated it then, and it caused so many problems because the indentation looked right but didn't match the brackets that I went over to "indented bracket" and have never look back. You still get some people who will change all code they find back to it though... X|

                                          Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together. Manfred R. Bihy: "Looks as if OP is learning resistant."

                                          "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
                                          "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt

                                          1 Reply Last reply
                                          0
                                          Reply
                                          • Reply as topic
                                          Log in to reply
                                          • Oldest to Newest
                                          • Newest to Oldest
                                          • Most Votes


                                          • Login

                                          • Don't have an account? Register

                                          • Login or register to search.
                                          • First post
                                            Last post
                                          0
                                          • Categories
                                          • Recent
                                          • Tags
                                          • Popular
                                          • World
                                          • Users
                                          • Groups