Namespaces and Naming conventions

F

Floppy Jellopy

How can you already have a web app if you haven;t even determined your
namespacing?
Ask yourself this: What makes a person object and how can i have one at both
the BOL and the DAL?
And frankley unless this is a class library...which its not..... who cares?




michaeltorus said:
HI

I've got an n-tier web app. The namespaces follow the layers in that I've
got a DAL namespace, a BOL namespace and a WEB namespace
What I'm tring to decide is the naming convention for my classes.

Theres 2 scenarios, firstly, Let's use a person object as an example:

If I name my person classes in both the DAL Layer and BOL layer to be ...

namespace BOL
{
class Person
{}
}

namespace DAL
{
class Person
{}
}



Then, whenever I create a person from the DAL Layer I have to reference it by using the qualified name:

namespace BOL
{
class Person
{
private DAL.Person _person = new DAL.Person();
}
}


The other scenario is to declare my person objects with e suffix of the
layer they reside in, so I can use the namespaces at the top without having
to include the fully qualified name each time I create a DAL object:
 
F

Floppy Jellopy

I disagree. The timer class you speak of is actually a timer in both
instances. A Person at the BOL might well be a Person but at the DAL would
be a PersonProvider. The two have very different reasons for being and would
not contain the same properties etc.

Either way this post has nothing whatsoever to do with asp.net other than
the fact that it happens to be asp.net application type.
Its ironic that the poster is expressing a concern for namespacing best
practises when they cant even get their message posted to the correct
newsgroup namespace.
 
M

michaeltorus

H

I've got an n-tier web app. The namespaces follow the layers in that I've got a DAL namespace, a BOL namespace and a WEB namespac

What I'm tring to decide is the naming convention for my classes.

Theres 2 scenarios, firstly, Let's use a person object as an example

If I name my person classes in both the DAL Layer and BOL layer to be ..

namespace BO

class Perso
{


namespace DA

class Perso
{}



Then, whenever I create a person from the DAL Layer I have to reference it by using the qualified name

namespace BO

class Perso

private DAL.Person _person = new DAL.Person()



The other scenario is to declare my person objects with e suffix of the layer they reside in, so I can use the namespaces at the top without having to include the fully qualified name each time I create a DAL object

using DAL

namespace BO

class PersonBo

private PersonDal _personDal = new PersonDal()




I'd like to know what is the preferred Method or standard for these kind of things ...

Also, Bear in mind the the full length of the namespaces is actually 4 or 5 words ....

Cheer

Mik
 
K

Karl Seguin

Mike:
You can take a look at the great:
http://msdn.microsoft.com/library/d...ef/html/cpconnetframeworkdesignguidelines.asp

which has advice on naming guidelines. I'm not sure that you'll find
anything specific to your problem though.

To be honest, I don't understand why you DAL has a class named "Person" in
it? Seems to me your DAL should be mapping between your relational store
and your business layer...why then would it be Person aware?

DataProvider.GetInstance.GetPerson(int userId);
DataProvider.GetInstance.GetPerson(string userName);

no?

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/ - New and Improved (yes, the popup is
annoying)
http://www.openmymind.net/faq.aspx - unofficial newsgroup FAQ (more to
come!)
 
K

Kevin Spencer

Even Microsoft has some problems with this sort of issue. For example, there
is a Timer class in 2 different namespaces in the .Net platform. I don't
know that there's a "right" way or "wrong" way to deal with it. Sometimes a
class name just is more understandable with a certain name, and using the
NameSpace solves the problem. Using "using" or "imports" statements, while
convenient, doesn't preclude the use of a NameSpace here and there from time
to time.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
The sun never sets on
the Kingdom of Heaven
 

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

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,007
Latest member
obedient dusk

Latest Threads

Top