Setting a classes accessors correctly across a business logic layer?
I have several classes within my business logic layer (some examples);
Atomic.Core.BLL.Client
Atomic.Core.BLL.Airport
Atomic.Core.BLL.Airline
When setting up the accessors on each class, I want to sometimes refer to objects within the BLL (as they are interlinked), but I want to do it efficiently and moreover with best practice.
I want to do something like this:
using System;
using System.Data;
//removed for brevity
namespace Atomic.Core.BLL.Airport
{
public class Airport
{
private int airport_id = 0;
public int AirportId
{
get { return airport_id; }
set { airport_id = value; }
}
private Airline airline = null;
public Airline Airline
{
get { return airline; }
set { airline = value; }
}
}
}
Visual Studio says that my AirlineObject
is a namespace being used as a type, which I totally understand, so can I add Airline to the Using list and shorthand it? How do I do that? using Atomic.Core.BLL.Airline as Airline
? I can't remember! Also, am I missing开发者_StackOverflow the point here and should I re-think what I am trying to do?
Help (as always) appreciated.
Best practice - do not name namespace and a class with the same name. Reasons? Here are some:
http://blogs.msdn.com/b/ericlippert/archive/2010/03/09/do-not-name-a-class-the-same-as-its-namespace-part-one.aspx
http://blogs.msdn.com/b/ericlippert/archive/2010/03/11/do-not-name-a-class-the-same-as-its-namespace-part-two.aspx
http://blogs.msdn.com/b/ericlippert/archive/2010/03/15/do-not-name-a-class-the-same-as-its-namespace-part-three.aspx
http://blogs.msdn.com/b/ericlippert/archive/2010/03/18/do-not-name-a-class-the-same-as-its-namespace-part-four.aspx
using Airline = Atomic.Core.BLL.Airline;
I wouldn't have all BLL classes in their own namespace. Dump them all into Atomic.Core.BLL, or a subsection - Atomic.Core.BLL.AiportLogic - if you need to be more specific.
精彩评论