#region....

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Jim

    #region....

    Are #region a bad thing or are they good?

    As far as I see it #region's are a bad thing as they let lazy programmmers
    have large and bloated methods divided into regions that then appear as
    small methods, they also show bad analsys and design when used in this
    way......


    Thoughts?

    Cheers

    Jim


  • BenoitM

    #2
    Re: #region....

    personally i find them very cool, but don't use them often...
    Most of the time, i find it handy to have a region for each implemented interface of a class...


    "Jim" <ssss> wrote in message news:ujR46FrUDH A.216@TK2MSFTNG P10.phx.gbl...[color=blue]
    > Are #region a bad thing or are they good?
    >
    > As far as I see it #region's are a bad thing as they let lazy programmmers
    > have large and bloated methods divided into regions that then appear as
    > small methods, they also show bad analsys and design when used in this
    > way......
    >
    >
    > Thoughts?
    >
    > Cheers
    >
    > Jim
    >
    >[/color]


    Comment

    • Jon Skeet

      #3
      Re: #region....

      "Jim" <ssss> <"Jim" <ssss>> wrote:[color=blue]
      > Are #region a bad thing or are they good?
      >
      > As far as I see it #region's are a bad thing as they let lazy programmmers
      > have large and bloated methods divided into regions that then appear as
      > small methods, they also show bad analsys and design when used in this
      > way......[/color]

      I would *very* rarely consider using a region *within* a method,
      however, regions are great for *grouping* methods, fields etc.

      --
      Jon Skeet - <skeet@pobox.co m>
      Pobox has been discontinued as a separate service, and all existing customers moved to the Fastmail platform.

      If replying to the group, please do not mail me too

      Comment

      • Chris Capel

        #4
        Re: #region....

        Even inside a function, a long list of repetitive code, like

        txts[0] = text0;
        txts[1] = text1;
        ....
        txts[30] = text30;

        will do great in a region of its own.

        "Jim" <ssss> wrote in message news:ujR46FrUDH A.216@TK2MSFTNG P10.phx.gbl...[color=blue]
        > Are #region a bad thing or are they good?
        >
        > As far as I see it #region's are a bad thing as they let lazy programmmers
        > have large and bloated methods divided into regions that then appear as
        > small methods, they also show bad analsys and design when used in this
        > way......
        >
        >
        > Thoughts?
        >
        > Cheers
        >
        > Jim
        >
        >[/color]


        Comment

        • Jay B. Harlow [MVP - Outlook]

          #5
          Re: #region....

          Jim,
          As a number of others have said. Bad use of a region does not make it bad.

          Like the others I use it to group code. These groupings tend to include:

          - Patterns - all the members for a pattern are in their own region. Seeing
          the title of the region indicates to me the class implements that pattern
          - Interfaces - all the members implementing an interface are in their own
          region. For larger interfaces I will create a number of region groups
          - Concepts - I'll create a region for overrides & interfaces that share a
          concept. Comparability for example. The IComparable interface & the Equals
          override I'll group together in a single region. Formatting is another
          concept I will group.
          - Static members - If the class has shared/static members that support the
          class, as oppose to the intent of the class, I will group them in a region.

          Most regions I place at the end of the class, Pattern & static regions tend
          to be at the top of the class.

          Rarely will I nest a region inside another region. And especially rarely
          will all the code in a class be in region. I like to see the 'important'
          members outside of a region, I put the less important 'support' members
          inside of regions.

          Hope this helps
          Jay

          "Jim" <ssss> wrote in message news:ujR46FrUDH A.216@TK2MSFTNG P10.phx.gbl...[color=blue]
          > Are #region a bad thing or are they good?
          >
          > As far as I see it #region's are a bad thing as they let lazy programmmers
          > have large and bloated methods divided into regions that then appear as
          > small methods, they also show bad analsys and design when used in this
          > way......
          >
          >
          > Thoughts?
          >
          > Cheers
          >
          > Jim
          >
          >[/color]


          Comment

          • Kevin Chandler

            #6
            Re: #region....

            "bad" is an understatement in this case.

            "Jim" <ssss> wrote in message news:eSi9zCsUDH A.584@TK2MSFTNG P12.phx.gbl...[color=blue]
            > Exactly, this is what I mean people hiding bad code inside a #region......
            >
            >
            >
            >
            > "Jon Skeet" <skeet@pobox.co m> wrote in message
            > news:MPG.198b59 54d39fcb3d98a20 5@news.microsof t.com...[color=green]
            > > Chris Capel <chris@nowhere. com> wrote:[color=darkred]
            > > > Even inside a function, a long list of repetitive code, like
            > > >
            > > > txts[0] = text0;
            > > > txts[1] = text1;
            > > > ...
            > > > txts[30] = text30;
            > > >
            > > > will do great in a region of its own.[/color]
            > >
            > > That sounds like the kind of thing that would suggest a refactoring in
            > > itself though, to me...
            > >
            > > --
            > > Jon Skeet - <skeet@pobox.co m>
            > > http://www.pobox.com/~skeet/
            > > If replying to the group, please do not mail me too[/color]
            >
            >[/color]


            Comment

            • Niall

              #7
              Re: #region....

              It's a pity this attitude isn't more common in regards to Multiple
              Inheritance :P

              Niall

              "Jay B. Harlow [MVP - Outlook]" <Jay_Harlow@ema il.msn.com> wrote in message
              news:OXf$MHsUDH A.2568@tk2msftn gp13.phx.gbl...[color=blue]
              > Jim,
              > As a number of others have said. Bad use of a region does not make it bad.
              >[/color]


              Comment

              Working...