Visual Basic

  1. Home
  2. Computing & Technology
  3. Visual Basic

Namespaces in VB.NET

Namespace Hierarchies

By Dan Mabbutt, About.com

Aug 23 2008

Everything so far has really just been syntax - the coding rules that you have to follow in using namespaces. But to really take advantage, you need two things:

  • A requirement for namespace organization in the first place. You need more than just a "Hello World" project before the organization of namespaces starts to pay off.
  • A plan to use them.

In general, Microsoft recommends that you organize your organization's code using a combination of your company name with the product name.

So, for example, if you're the Chief Software Architect for Dr. No's Nose Knows Plastic Surgery, then you might want to organize you namespaces like ...

DRNo
   Consulting
      ReadTheirWatchNChargeEm
      TellEmNuthin
   Surgery
      ElephantMan
      MyEyeLidsRGone

This is similar to .NET's organization ...

Object
   System
      Core
         IO
         Linq
      Data
         Odbc
         Sql

The multilevel namespaces are achieved by simply nesting the namespace blocks.

Namespace DRNo
   Namespace Surgery
      Namespace MyEyeLidsRGone
' VB Code
      End Namespace
   End Namespace
End Namespace

... or ...

Namespace DRNo.Surgery.MyEyeLidsRGone
' VB Code
End Namespace

Explore Visual Basic

By Category

About.com Special Features

Visual Basic

  1. Home
  2. Computing & Technology
  3. Visual Basic
  4. Using VB.NET
  5. Using Namespaces - Namespaces keep VB.NET organized

©2009 About.com, a part of The New York Times Company.

All rights reserved.