[英]Designing a Multi-Tier Application (Template style)
Im planning to design a project (n-tier) that is easy to customize and maintain without compromising efficiency... here is the draft of my (unique :)) design layout base on what I learned on how to built ntierarchitecture... 我正在计划设计一个易于自定义和维护而不影响效率的项目(n层)...这是我(unique :))设计布局的草稿,该设计基于我对如何构建ntierarchitecture的了解...
The project is composed of 3 DLLs (+1 for Helper Classes) and the UI 该项目由3个DLL(Helper类为+1)和UI组成
BusinessRules.dll (Compose of 2 subfolders ValueObjects(DTO) and BusinessObjects) BusinessRules.dll(由2个子文件夹ValueObjects(DTO)和BusinessObjects组成)
AppDomainRules.dll (i put here the domain driven classes like registration, admission, sale service classes, will use the Business Objects and VOs) AppDomainRules.dll(我将域驱动的类(如注册,准入,销售服务类)放在此处,将使用业务对象和VO)
DataAccessLayer.dll here is the code: DataAccessLayer.dll的代码如下:
// in BusinessRules.DLL, sub folder ValueObject //在BusinessRules.DLL中,子文件夹ValueObject
public class Person
{
// getters and setters
public string ID { get; set; }
public string Name { get; set; }
}
// in BusinessRules.DLL, sub folder Business Objects
public class PersonBLL
{
public void AddNewPerson(Person Person)
{
new PersonDAL().SaveNewPerson(Person);
}
//side-question:
//should I inherit the Person VO and do it like this
//public void AddNewPerson()
//{
// new PersonDAL().SaveNewPerson(this);
//}
// which is more efficient???
}
// in DataAccessLayer.DLL
public class PersonDAL
{
public void SaveNewPerson(Person Person)
{
// Save to DB
}
}
// in AppDomainRules.DLL, base class
public abstract class RegistrationTemplate
{
public virtual void RegisterNewPerson(Person m)
{
new PersonBLL().AddNewPerson(m);
}
}
//Client 1 registration domain logic
public class RegistrationForClient1 : RegistrationTemplate
{
// will use the template
}
// Client 2 registration domain logic
public class RegistrationForClient2 : RegistrationTemplate
{
// overrides the template
public override void RegisterNewPerson(Person m)
{
// change the behavior of PersonBLL.AddNewPerson
// different implementation
}
}
// UI Implementation for Client1
static void Main(string[] args)
{
Person m = new Person()
{
ID = "1",
Name = "John Mortred"
};
new RegistrationForClient1().RegisterNewPerson(m);
}
My priorities/Goals are: 1. Efficiency 2. Maintainability / Customizable / Reliable /Scalability 3. RAD (fast development of the system) 我的优先事项/目标是:1.效率2.可维护性/可定制/可靠/可伸缩性3. RAD(系统的快速开发)
My questions: In your opinion, 1. Is the design flawed? 我的问题:您认为:1.设计是否有缺陷? how about code efficiency? 代码效率如何? performance? 性能? 2. Do I violate some rules on OOP archi or Tiered design? 2.我是否违反有关OOP架构或分层设计的某些规则? 3. Is this design Loosely/ Low coupled? 3.该设计是否松散/低耦合? 4. Can I achieve my Goals using this? 4.我可以以此实现我的目标吗? 5. Suggestions? 5.建议?
thanks in advance :) 提前致谢 :)
I would advise figuring out what your program needs to do, before constraining it to a specific design. 我建议您先确定程序需要做什么,然后再将其约束到特定的设计中。
How this might not be flawed for a simple stand alone application that allows you to store and read users, it might not be a good design for a multi-user system that needs to have offline/online features and functionality. 对于允许您存储和读取用户的简单独立应用程序来说,这可能没有什么缺陷,对于需要具有脱机/联机功能的多用户系统,这可能不是一个好的设计。
Unless you are making a "fun" project, always figure out what you need to do, before you build it. 除非您要创建一个“有趣”的项目,否则在构建它之前,请务必弄清楚您需要做什么。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.