473,385 Members | 1,813 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Namespaces and Visibility


Do sub Namespaces have visibility to parent class. ie.
I am trying to develop an application that is made up of
modules and the main module contains a variables class
that contains all the variables needed for the
application.

eg.

MainModule Namespace
Contains MainMod Class
Variables Class

MainModule.SubModule Namespace
Contains SubMod Class

MainMod class populates the variables class and is the
main entry point of the application and it also calls
methods in the SubMod Class. Can SubMod Class get access
to the Variables Class and its members.

If not how should this be designed/developed.

Thanks Kel.

Jul 21 '05 #1
3 1484
Sure, but you either have to import them or qualify them with the full name.

Namespaces have no "visibility" issues - they're always visible and public.
What's inside them is what counts.
--
____________________
Klaus H. Probst, MVP
http://www.vbbox.com/

"kele" <ke********@yahoo.com.au> wrote in message
news:36****************************@phx.gbl...

Do sub Namespaces have visibility to parent class. ie.
I am trying to develop an application that is made up of
modules and the main module contains a variables class
that contains all the variables needed for the
application.

eg.

MainModule Namespace
Contains MainMod Class
Variables Class

MainModule.SubModule Namespace
Contains SubMod Class

MainMod class populates the variables class and is the
main entry point of the application and it also calls
methods in the SubMod Class. Can SubMod Class get access
to the Variables Class and its members.

If not how should this be designed/developed.

Thanks Kel.

Jul 21 '05 #2

It would still not work, because you can not have
circular dependencies so if you add the reference to the
SubModule Namespace in the MainModule you can call
methods etc in the SubModule classes. But you can not
access the Variables class from the SubModule classes.

The only way I can think of getting around this is to
have the Variables Class in a module on its own (which
doesn't make as much sence).

I just wanted to know what Microsofts best practice is
for this type of design.
Jul 21 '05 #3
Kele,
As Klaus suggested NAMESPACES do not reference each other, hence there is no
chance of a circular dependencies!

..NET is able to handle correctly if you have two types (type as in classes,
structures, interfaces) that reference each other within the same assembly.

The problem comes in when you have two Assemblies reference each other,
which can lead to circular dependencies, as the first needs to be compiled
before the second, however the second needs to be compiled before the first.

If I have a need for two assemblies referencing each other, I normally
implement the Separated Interface.

http://www.martinfowler.com/eaaCatal...Interface.html

In the SubModule, define an Interface that the MainModule implements, that
the SubModule uses. Alternatively define the Interface in a third assembly.
The MainModule is then free to reference the SubModule, while the SubModule
is not explicitly dependent on the MainModule.

Hope this helps
Jay

"kele" <ke********@yahoo.com.au> wrote in message
news:45****************************@phx.gbl...

It would still not work, because you can not have
circular dependencies so if you add the reference to the
SubModule Namespace in the MainModule you can call
methods etc in the SubModule classes. But you can not
access the Variables class from the SubModule classes.

The only way I can think of getting around this is to
have the Variables Class in a module on its own (which
doesn't make as much sence).

I just wanted to know what Microsofts best practice is
for this type of design.

Jul 21 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Jonathan | last post by:
Hi, I've read through quite a number of postings on here so far and have seen what look like very simply, reasonable answers to this question, however I am still completely unable to do what I...
3
by: Jukka K. Korpela | last post by:
I have noticed that the meaning of visibility: collapse has been discussed on different forums, but with no consensus on what it really means. Besides, implementations differ. The specification...
12
by: lawrence | last post by:
The following function correctly makes everything invisible but then fails to turn the one chosen DIV back to visible. I imagine I'm getting the syntax of the variable wrong? I've tried this with...
4
by: lawrence | last post by:
Can anyone tell me why this code works in Netscape 7.1 but not in IE??? <SCRIPT type='text/javascript'> function makeVisible(nameOfDiv) {...
8
by: TTroy | last post by:
I have a few questions about "scope" and "visibility," which seem like two different things. To me "visibility" of the name of a function or object is the actual code that can use it in an...
3
by: kele | last post by:
Do sub Namespaces have visibility to parent class. ie. I am trying to develop an application that is made up of modules and the main module contains a variables class that contains all the...
4
by: mabster | last post by:
Hi folks, I'm just starting to come to grips with web services in general, and I'm in the process of making some test projects based on example code from MSDN etc. When I create a new ASP.NET...
11
by: -D- | last post by:
How can I turn the visibility of the xml control on or off? <%@ Control Language="c#" AutoEventWireup="false" Codebehind="TopNavBar.ascx.cs" Inherits="compass.user_controls.TopNavBar"...
3
by: 2b|!2b==? | last post by:
I have a C++ library partitioned by namespaces. I want to export some of the functions in one of the namespace - how do I do it. Assuming I have the macro MYAPI_EXPORTS #defined to be a declspec...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.