Results 1 to 5 of 5

Thread: Regions - Any "standards"? [RESOLVED]

  1. #1

    Thread Starter
    Frenzied Member StrangerInBeijing's Avatar
    Join Date
    Mar 2005
    Location
    Not in Beijing
    Posts
    1,666

    Resolved Regions - Any "standards"? [RESOLVED]

    Hi,

    Regarding the use of "regions" in your code to organize things.

    Are there any rules that tell you how not to use it, especially when it comes to nesting?

    I nest the stuff like hell, but was told I am not to use nested regions for my work code.

    OK, I can change that, but for my personal project, I use my own style, but would like to stick to any “unwritten” rules you pro’s might have
    Last edited by StrangerInBeijing; Sep 8th, 2005 at 03:16 AM. Reason: [RESOLVED]
    Install and Configure Eclipse For both Java and PHP development
    Accessible Ajax/jQuery Forms Degrade gracefully with JavaScript Disabled

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: Regions - Any "standards"?

    The use of regions is purely for the developers benefit. It has no effect on anything other than how you view the code in the IDE. I try not to nest regions because it just makes it more difficult to get to the stuff I want, but if I have a particular region that is getting really large and there is a logical way to section it, then I'll think about nesting them. It's purely for the developers convenience though, and has no impact on your code whatsoever. If your company is of the view that nested regions make it more difficult to read code then that's their decision, but you should continue to do whatever you see fit in your own personal work.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  3. #3
    l33t! MrPolite's Avatar
    Join Date
    Sep 2001
    Posts
    4,428

    Re: Regions - Any "standards"?

    as jmc says it's up to you
    however 2 notes that might relate to this
    if you have a really long class and you want to break into different regions, you might want to consider c#2005's partial classes (if you are planning to get that).

    vb.net doesnt allow regions inside functions and C# does. so if you're moving from vb.net you might not already know this. However, it might be a bad idea to use regions inside a function, because then it would mean your function is too long (it's usually a good idea to have shorter functions).
    rate my posts if they help ya!
    Extract thumbnail without reading the whole image file: (C# - VB)
    Apply texture to bitmaps: (C# - VB)
    Extended console library: (VB)
    Save JPEG with a certain quality (image compression): (C# - VB )
    VB.NET to C# conversion tips!!

  4. #4

    Thread Starter
    Frenzied Member StrangerInBeijing's Avatar
    Join Date
    Mar 2005
    Location
    Not in Beijing
    Posts
    1,666

    Re: Regions - Any "standards"?

    thanks guys

    reason for asking, is that I want to share code in my ssdev project if someone need help, whoever he/she are, so want to keep things to some kind of "standard".

    partial classes...that's sth new..will look it up

    thanks again
    Install and Configure Eclipse For both Java and PHP development
    Accessible Ajax/jQuery Forms Degrade gracefully with JavaScript Disabled

  5. #5
    Hyperactive Member Sgt-Peppa's Avatar
    Join Date
    Mar 2003
    Location
    Munich - Germany
    Posts
    476

    Re: Regions - Any "standards"?

    I usually use regions that describe the kind of Functions, or members I use in my class.
    For example:
    Code:
    #region using
    .
    .
    .
    #endregion
    
    #region PrivateMembers
    .
    .
    .
    #endregion
    
    #region PublicProperties
    .
    .
    .
    #endregion
    
    #region PublicConstructors
    .
    .
    .
    #endregion
    
    #region PrivateMethods
    .
    .
    .
    #endregion
    
    #region PublicMethods
    .
    .
    .
    #endregion
    
    #region PublicStaticMethods
    .
    .
    .
    #endregion
    I do nest one more level inside the regions but thats absolutely it.
    For example
    Code:
    #region PrivateMethods
    	#region static
    	#endregion
    	#region regular
    	#endregion
    #endregion
    This might not be the best use of them and theres probably millions of different ways on how to structure your code but I like it this way. And thats exactly how you should handle that topic. Do what you like, or how your company tells you to use them.
    This was just to give you an idea on how someone else is using them.

    HTH,

    Stephan
    Keep Smiling - even if its hard
    Frankie Says Relax, wossname Says Yeah!
    wossname:--Currently I'm wearing a gimp suit and a parachute.
    C# - Base64 Blog

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width