Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / C# / March 2008

Tip: Looking for answers? Try searching our database.

Namespaces and Inheritance

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Robert Cramer - 13 Mar 2008 04:39 GMT
Is it perfectly acceptable, from a "conventions" or "best practices" point
of view to have a class in one namespace extend a class in another
namespace?

I just came across this state of affairs in the .NET Framework itself and,
at first, it seemed somehow like a "bad thing" (in part because namespaces
are intended to group classes that serve some common purpose) - but after
about two seconds of thinking about it, I'm thinking that there is
absolutely nothing wrong with doing this - and in many situations, like in
large frameworks, it would even be unavoidable.

And example from the .NET Frameowork is:
     System.ComponentModel.ComponentResourceManager
which extends
     System.Resources.ResourceManager

Thoughts? Opinions? - specifically regarding the idea that it is (or is not)
perfectly acceptable to have a base class in one namespace, and then extend
that class in an entirely different namespace?

FWIW, I do understand that the classes, themselves, don't care about the
namespace in which they exist - at least not beyond qualifying references to
specific external classes.

Thanks.
Brendan G - 13 Mar 2008 05:47 GMT
This is just basic OOP principles, isn't it?

> Is it perfectly acceptable, from a "conventions" or "best practices" point
> of view to have a class in one namespace extend a class in another
[quoted text clipped - 21 lines]
>
> Thanks.
Roger Frost - 13 Mar 2008 05:54 GMT
> Is it perfectly acceptable, from a "conventions" or "best practices" point
> of view to have a class in one namespace extend a class in another
[quoted text clipped - 21 lines]
>
> Thanks.

If the extended class adds functionality specific to its namespace, why not
put it there?

Signature

Roger Frost
"Logic Is Syntax Independent"

Peter Duniho - 13 Mar 2008 07:09 GMT
> Is it perfectly acceptable, from a "conventions" or "best practices"  
> point
> of view to have a class in one namespace extend a class in another  
> namespace?

I think it depends on your definition of "extend".  But for common  
definitions, such as "inherit" or (now with C# 3.0) writing an extension  
method for the class, I'd say that not only is it acceptable, it's the  
most common way of doing it.

Every .NET Forms application has at least one custom Form-derived class,  
and that class is never in System.Windows.Forms.

Similar situations may well exist within a development team.  I don't see  
anything fundamentally wrong with this kind of extension crossing  
namespace boundaries.

Pete

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.