Use of NAMESPACE


T

Tom Edelbrok

I'm upgrading from VB6 to VS.Net Pro 2003, and am trying to plan a way of
using NAMESPACE's.

Under VB6 we had a variety of global procedures stored in a series of
modules, as well as in classes. These were 'included' into a number of
independant VB 6.0 projects. It seems to me that under VB.net we have two
choices for implementing the new NAMESPACE idea:

a) Either we continue to have a series of modules, and place namespace's in
them. These modules are part of each individual VB.Net project.

b) Or, we take our common modules (utility procedures and functions) and
place them into DLL's (Assemblies now?) with their own namespaces. Each
project that needs the common modules can either import the namespace or
else reference utilties explicity with a namespace prefix.


My knowledge of VB.net as you can see is limited, however maybe someone can
give me some pointers. We don't want to implement something and then have to
spend enormous amounts of time undoing it later.

Thanks in advance,

Tom
 
Ad

Advertisements

M

Manohar Kamath

Tom,

In .NET, one needs to think less of a module, and more of a class. Each
class has it's own responsibilities and data. E.g. a Circle class. That
said, modules in VB may not correspond one-to-one with the classes you will
design in VB.NET (or any .NET language).

Namespace on the other hand is a collection of classes that have similar
functions. E.g. Shapes namespace. This namespace itself could be included in
a broader namespace, etc.

So, separate your functions and form a class, and then place them in a
namespace. The namespace can span multiple assemblies (DLL, exe, etc), but I
find it helpful when they are in one. It does not matter how many assemblies
you create -- creating more makes easy distribution, but difficult
maintenance.

Dug up a simple article on the subject:
http://www.cnn.com/2005/SHOWBIZ/Movies/02/26/oscars.razzies.reut/index.html

Hope that helps.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top