
N层应用程序是分布在分布式网络中的三个或更多个单独计算机之间的程序。
最常用的n层方式是3层应用程序,它分为三类。
此体系结构模型为工具研发人员提供了最大灵活性的可重用应用程序/系统。
在N层中,“N”指的是正在使用的层数或层数,如 - 2层,3层或4层等 。 它也被称为“ 多层 架构”。
n层架构是经过市场验证的硬件架构建模。 它借助提供可伸缩性,安全性,容错性,可重用性和可维护性的解决方案软件3层结构,适合支持企业级客户端 - 服务器应用程序。 它可以帮助研发人员建立灵活且可重用的应用程序。
此处描述了n层平台的图形表示 - 表示层,应用程序层和层。


image.png
根据规定,这三层可以进一步细分为不同的子层。
一些应用这些架构的热门网站是
要记住一些常见用语,以便更明白地理解概念。
客户端 - 服务器体系结构:它是一种体系构架模型,其中客户端(一个程序)从服务器(另一个程序)请求服务, 即它是借助因特网或通过内联网提供的请求 - 响应服务。
在此模型中, 客户端将作为一组程序/代码,通过网络执行一组操作。 另一方面软件3层结构, Server是一组另一个程序,它按照请求将结果集发送到客户端系统。
平台:在计算机科学或硬件市场中,平台是应用程序可以运行的平台。 它由硬件和工具组合而成,具有内嵌指令,供处理器/微处理器执行特定操作。

:它是一种有组织的信息集合,因此可以轻松访问,管理和升级。
有不同类型的N层体系结构,如3层体系结构,2层体系结构和1层体系结构。
首先,我们将发现3层架构,这特别重要。
通过查看图示,您可以轻松识别3层架构有三个不同的层。

image.png
在这里,我们采用了一个简单的学生方式示例来理解所有这三个层次。 它包括有关学生的信息 - 姓名,地址,电子邮件和截图。

用户界面层或表示层

image.png
private void DataGrid1_SelectedIndexChanged(object sender, System.EventArgs e)
{
// Object of the Property layer
clsStudent objproperty=new clsStudent();
// Object of the business layer
clsStudentInfo objbs=new clsStudentInfo();
// Object of the dataset in which we receive the data sent by the business layer
DataSet ds=new DataSet();
// here we are placing the value in the property using the object of the
//property layer
objproperty.id=int.Parse(DataGridl.SelectedItem.Cells[1].Text.ToString());
// In this following code we are calling a function from the business layer and
// passing the object of the property layer which will carry the ID till the database.
ds=objbs.GetAllStudentBsIDWise(objproperty);
// What ever the data has been returned by the above function into the dataset
//is being populate through the presentation laye.
txtId.Text=ds.Tables[0].Rows[0][0].ToString();
txtFname.Text=ds.Tables[0].Rows[0][1].ToString();
txtAddress.Text=ds.Tables[0].Rows[0][2].ToString();
txtemail.Text=ds.Tables[0].Rows[0][3].ToString();
业务访问层 -
这是业务层的用途,它接受来自应用层的数据并将其释放给数据层。
// this is the function of the business layer which accepts the data from the
//application layer and passes it to the data layer.
public class clsStudentInfo
{
public DataSet GetAllStudentBsIDWise(clsStudent obj)
{
DataSet ds=new DataSet();
ds=objdt.getdata_dtIDWise(obj);// Calling of Data layer function
return ds;
}
}

数据访问层
这是数据层功能,它从业务层接收数据并对执行必要的操作。
// this is the datalayer function which is receiving the data from the business
//layer and performing the required operation into the database
public class clsStudentData // Data layer class
{
// object of property layer class
public DataSet getdata_dtIDUise(clsStudent obj)
{
DataSet ds;
string sql;
sql="select * from student where Studentld=" +obj.id+ "order by Studentld;
ds=new DataSet();
//this is the datalayer function which accepts the sql query and performs the
//corresponding operation
ds=objdt.ExecuteSql(sql);
return ds;
}
}
单层或单层架构:
它是最简单的一个,因为它等同于在个人计算机上运行应用程序。 运行应用程序所需的所有部件都在单个应用程序或服务器上。
表示层,业务逻辑层和数据层都位于一台机器上。
好处
缺点
考虑到软件人员应当完全控制架构的所有层,有关n层架构的提示如下
尝试使用soap XML等技术尽可能地将图层与其它图层分离。使用一些自动化工具生成业务逻辑层和关系层(数据层)之间的映射。 可以帮助建模这些映射技术的软件是 - Entity Framework和Hibernate for .Net等。在客户端演示者层中,尽可能将所有客户端的公共代码放到单独的库中。 这将最大化所有类别客户端的代码可重用性。可以将缓存层添加到现有层中以加快性能。
本文来自电脑杂谈,转载请注明本文网址:
http://www.pc-fly.com/a/jisuanjixue/article-121914-1.html
小王子
要掌控这门技能