Wrox Programmer Forums

Need to download code?

View our list of code downloads.

| FAQ | Members List | Search | Today's Posts | Mark Forums Read
Pro VB.NET 2002/2003 For advanced Visual Basic coders working .NET version 2002/2003. Beginning-level questions will be redirected to other forums, including Beginning VB.NET.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Pro VB.NET 2002/2003 section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old October 21st, 2003, 03:39 AM
Registered User
Join Date: Oct 2003
Location: , , .
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Namespace

Hi - I am working through the example data layer in chap 11 of Prof. VB.NET - Can someone clarify, why does the writer create a namespace when he/she's only got one class in the class library. I thought the idea of creating a namespace gives you the ability to group classes together and then just use something like - imports myclasses
Any comments much appreciated!
Reply With Quote
  #2 (permalink)  
Old October 21st, 2003, 08:34 AM
planoie's Avatar
Friend of Wrox
Points: 16,481, Level: 55
Points: 16,481, Level: 55 Points: 16,481, Level: 55 Points: 16,481, Level: 55
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
Join Date: Aug 2003
Location: Clifton Park, New York, USA.
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts

You are correct, that's one of the general intents of namespaces. You can wrap a class inside of a namespace so that you can organize classes. With VB.Net an assembly has a root namespace which defines the main namespace that everything lives in. You create classes, and they live within the root namespace. If you were to create a sub class inside of the class you'd be at the third level.

Public Class MyClass
    Public Class SubClass
    End Class
End Class


Namespace MyNamespace
    Public Class MyClass
        Public Class SubClass
        End Class
    End Class
End Namespace


Reply With Quote
  #3 (permalink)  
Old October 21st, 2003, 09:15 AM
Friend of Wrox
Join Date: Jun 2003
Location: Sparks, NV, USA.
Posts: 101
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to jlick

I have not read that far into the book, but there are other reasonse for namespaces. For instance, in your data layer, lets say you want to have have a set of classes that perform similar actions. A query object for example. You may want to have namespaces like DataAccess.OracleDA, DataAccess.DB2DA, DataAccess.MsSqlServerDA all haveing a query object that is specific to the data base. This allows you to not have to worry about using the same class name (Query), but for the developer using the data access layer they know that they go to the namespace for the server they are interested in, and the object will always be called Query. Now these Query objects may all inherit from DataAccess's Query object which can not be instantiated, but is the bases for the classes that are in the sub-namespaces.

Just a thought.

John R Lick
Reply With Quote

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Two namespace contain same name nir_pankaj C# 1 February 21st, 2007 12:30 PM
Namespace ~Bean~ Classic ASP Basics 2 June 3rd, 2005 02:31 PM
namespace Ibn_Aziz C# 2 December 25th, 2003 05:41 AM
namespace within namespace Bill Crawley XML 1 December 11th, 2003 10:59 AM

All times are GMT -4. The time now is 12:41 AM.

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.