11.19(eleven point one nine)

Entity在三层架构中的作用:

1、实现面向对象思想中的”封装”;2、贯穿于三层,在三层之间传递数据;(注:确切的说实体层贯穿于三层之间,来连接三层)3、对于初学者来说,可以这样理解:每张数据表对应一个实体,即每个数据表中的字段对应实体中的属性(注:当然,事实上不是这样。为什么?1>,可能我们需要的实体在数据表对应的实体中并不存在;2>,我们完全可以将所有数据表中的所有字段都放在一个实体里)4、每一层(UI—>BLL—>DAL)之间的数据传递(单向)是靠变量或实体作为参数来传递的,这样就构造了三层之间的联系,完成了功能的实现。但是对于大量的数据来说,用变量做参数有些复杂,因为参数量太多,容易搞混。比如:我要把员工信息传递到下层,信息包括:员工号、姓名、年龄、性别、工资....用变量做参数的话,那么我们的方法中的参数就会很多,极有可能在使用时,将参数匹配搞混。这时候,如果用实体做参数,就会很方便,不用考虑参数匹配的问题,用到实体中哪个属性拿来直接用就可以,很方便。这样做也提高了效率。

————————

The role of entity in the three-tier architecture:

1. Realize the “encapsulation” in the object-oriented idea; 2. It runs through the three layers and transfers data between the three layers; (Note: specifically, the entity layer runs through the three layers to connect the three layers) 3. For beginners, it can be understood that each data table corresponds to an entity, that is, the fields in each data table correspond to the attributes in the entity (Note: of course, this is not the case. Why? 1 >, the entity we need may not exist in the entity corresponding to the data table; 2 >, we can put all fields in all data tables in one entity) 4. Data transfer between each layer (UI – & gt; Bll – & gt; DAL) (one-way) It is transferred by variables or entities as parameters, which constructs the relationship between the three layers and completes the realization of the function. However, for a large amount of data, it is complicated to use variables as parameters because there are too many parameters, which are easy to be confused. For example, I want to transfer employee information to the lower level, including employee number, name, age, gender, salary If variables are used as parameters, there will be many parameters in our method. It is very possible to confuse parameter matching when using them. At this time, it will be convenient to use entities as parameters without considering the problem of parameter matching. It is convenient to use which attribute in entities directly. This also improves efficiency.