Solved

How do you handle namespace conflicts?

Posted on 2009-04-10
9
299 Views
Last Modified: 2012-05-06
I use fxcop and one of the violations is to use an existing .NET namespace such as Configuration, ConfigurationManager, Security.  I like the rule.  It avoids namespace conflicts.  But what are some other names to give those spaces?  How are others naming them?
0
Comment
Question by:brettr
  • 5
  • 2
  • 2
9 Comments
 
LVL 12

Accepted Solution

by:
williamcampbell earned 250 total points
Comment Utility
You can have a global namespace for you product or company

namespace bretterscoolcode.configuration
{
}

namespace okcompany.bretteriscooler.code.configuration
{
}

Use the dots luke ..

0
 
LVL 22

Assisted Solution

by:p_davis
p_davis earned 250 total points
Comment Utility
How about prefixing the names with your applications name?
0
 

Author Comment

by:brettr
Comment Utility
Using dots like thecompany.Enterprise.Configuration makes no difference.  fxcop will even point out the fully qualified namespace is incorrect:

Error, Certainty 95, for TypeNamesShouldNotMatchNamespaces
{
    Target       : mycompany.Enterprise.Configuration  (IntrospectionTargetType)
    Resolution   : "The type name 'Configuration' conflicts in whole
                   or in part with the namespace name 'System.Configuration'
                   defined in the .NET Framework. Rename the type to eliminate
                   the conflict."
    Help         : http://msdn2.microsoft.com/ms182257(VS.90).aspx  (String)
    Category     : Microsoft.Naming  (String)
    CheckId      : CA1724  (String)
    RuleFile     : Naming Rules  (String)
    Info         : "Identifiers which conflict in whole or in part with
                   namespace names should be avoided. Names that describe
                   the purpose or contents of a type are preferred."
0
 
LVL 22

Expert Comment

by:p_davis
Comment Utility
i meant like if your application was called MyApp

you can do MyAppSecurity
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 22

Expert Comment

by:p_davis
Comment Utility
or use acronyms

MASecurity
0
 

Author Comment

by:brettr
Comment Utility
I was referring to williamcampbell.  I don't want to use the company name or acronums of it in the namespace.  Cheesy.
0
 
LVL 22

Expert Comment

by:p_davis
Comment Utility
You asked for suggestions, i gave one. I don't think there is a reason to make fun of a suggestion that is perfectly valid.
0
 
LVL 12

Expert Comment

by:williamcampbell
Comment Utility
Go into fxcop and turn of this warning ... it's stupid in my opioion

mmm cheese

0
 
LVL 22

Expert Comment

by:p_davis
Comment Utility
that's it, now i am hungry.
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now