Best naming conventions

A

Andy B.

I have a namespace in my project where all of the forms, controls and
related code are that have to do with a particular section of the project.
For example, I have a module, an enum and 5 forms in the namespace called
News. The problem is one of the forms called News has a naming conflict with
the Module also called News. What is the best naming convention for forms
and modules so they don't conflict like that?
 
M

Michel Posseth [MCP]

Andy


Global.News for the module

Forms.News for the form


HTH

Michel
 
A

Andy B.

I need the enum, module, and all related controls/forms in the same
namespace. News is a feature of the application.

1. What should I call the namespace?
2. Since there is a name conflict between News module and News form called
the same thing, how should I fix this?

What exactly are Global.News and Forms.News?

I need a logical way to divide the application into well named namespaces.
 
M

Michel Posseth [MCP]

Hello Andy

The most common way with namespaces is
company_name.library_name.your_subnamespace
This said Global is normally a special namespace where all shared code
should be in ( it is a special namespace )
The outermost namespace of every assembly is in the global scope

With my short not so verry good example i guess , i tried to explain the
story above

HTH

Michel
 
A

Andy B.

Since there is only me doing this project and I don't plan on
importing/using anything else other than what originally came with .net
framework, Safe to say that I don't need to prepend CompanyName to the
beginning of all of my namespaces. If it helps, here is the namespace layout
I have already. Remember that ApplicationName is prepended to the beginning
of these namespaces. I want to make things a little easier to use here, but
here is the current layout.

Modules - Where all modules in the application are. This includes news.
Controls.News - Contains all of the controls required to make the UI work
with the news feature.
Forms - where the the appplication level UI is
Website - Root namespace of the application.

The code for the News feature is scattered around between all of these
namespaces. I want to make a namespace like EternityRecords.Website.News
that holds everything needed to make the news feature work. I can do this
with no problem, but I am having trouble coming up with a replacement name
for either News Module or News Form. Do you have any ideas how to name
Forms, Modules and different things in a single namespace like this and also
avoid naming conflicts?
 
M

Martin H.

Hello Andy,

The best thing would be if you changed the names accordingly,
e.g. frmNews for the form, enNews for the enumeration, modNews for the
module etc. Apart from the fact that there are no more name conflicts,
it's also easier for you to debug your software as you see right away
which "News" your code tries to access.

Best regards,

Martin
 
A

Andy B.

Ok. Doesn't this go against the .net naming conventions? I just read about
that and it had illuded to the fact that you shouldn't put ModNews or EnNews
for type names. Would it be better if I put all of the UI elements for the
news feature in a namespace called EternityRecords.Website.News.UI and leave
the modules for EternityRecords.Website.News? or is there a better namespace
naming rule to follow?
 
M

Martin H.

Hello Andy,

Ok. Doesn't this go against the .net naming conventions? I just read
about that and it had illuded to the fact that you shouldn't put
ModNews or EnNews for type names.

I would not care too much about naming conventions other people make.
It just depends what is best for you. If you think that having 5
different objects with the same name is OK for you, just do it. If you
think that its better to see what an object is be giving it a prefix, do
it. I give all my objects prefixes (frm, cmd, cmb etc.) since the good
old VB6 days. Because to me it makes the code easier to read. But as
each programmer has a different style, it might not be the right thing
for you.
Would it be better if I put all of the UI elements for the
news feature in a namespace called EternityRecords.Website.News.UI
and leave the modules for EternityRecords.Website.News? or is there a
better namespace naming rule to follow?

As I said above: It's up to you. If this project of yours is not a huge
one, I suggest that you try out various styles to find the one that
suits you best. Writing a program is similar to raising a child - there
are different styles to do it. All of them may work although they are
different. But not each style works for every person.

Best regards,

Martin
 

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