Hilton Giesenow's Jumbled Mind

Thursday, July 15, 2004

#Region Standards in Visual Studio.Net

Today I had a few thoughts about regions in Visual Studio.Net. For those unprivileged few who have to code in the Web Matrix Project (which I did for a few months) or Visual Notepad ++ ;-) Notepad, Visual Studio.Net allows you to group sections of source code together so that they can be expanded and contracted when you want, kind of like folders in Windows Explorer. Also, what some people don't know is that you can nest regions inside of one another. With this in mind, I started thinking about what some standards might look like here.

Standards, as we all know, is often a hairy topic. We've seen Hungarian Notation cause its debates (See MSDN Naming Guidelines). BTW, Chris Sells joked (in his DotNet Rocks! interview) about case sensitivity in C# being the "new Hungarian Notation" - that might explain SOME purpose in it for us Visual Basic.Net guys.

Anyways, the following are recommendations for first- and second-level region regions. Additional regions can be added at any levels at the developer’s discretion if it is felt that these will be in keeping with the goals of enhanced readability and navigation. In addition, regions that are unused are simply left out. If a sub-level is presented (e.g. see Methods below), the regions appear in descending order of scope. These sub regions are indented according to level.

Normal classes
These are the base regions for each class and are adjusted for Web Forms, Web Services, etc. as discussed below.
  • Variable Declarations
  • Constants
  • Enums
  • Properties
  • Constructors
  • Methods
     o Public Methods
     o Protected Methods
     o Private Methods
  • Code To Store

Web Forms / User Controls
As before, but with additions as follows:
  • Methods
     o Page Control Events
     o Lookup Methods (many of which may be public, e.g. for grid binding lookups)
     o …

Web Services
As before, but with additions as follows:
  • Methods
     o Public Methods
          Data Retrieval Methods
          Data Updating Methods

I'd love to hear anybody's thoughts on this.

0 Comments:

Post a Comment

<< Home