OO + 3层设计问: [英] OO + 3-Tier design Q

查看:49
本文介绍了OO + 3层设计问:的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用OO + 3层设计开发一个ASP.NET应用程序,这是一个

场景:

如果有一个People类其定义如下,

class人物

{

字符串ID;

字符串FirstName;

string LastName;

string地址;

string电话;

}


然后有2个webform页面,一个只显示ID,FirstName和

LastName属性

人物对象,但另一个将显示所有属性。


Q1:两个webform页面都可以使用相同的People对象,或者我应该创建

并为每个webform声明两个

类如下所示页?哪一个更好维护

和性能?


类BasePeople

{

字符串ID ;

string FirstName;

string LastName;

}


class人物:BasePeople

{

字符串地址;

字符串电话;

}


Q2:数据层应该读取db的所有列和Biz Logic

层选择必填字段

填写People对象?

或数据层一开始只从db中获取所需的列?

提前谢谢。

解决方案

< blockquote>

" news.microsoft.com" < re ***** @ usawrote in message

news:u9 ************** @ TK2MSFTNGP05.phx.gbl ...


我正在尝试使用OO + 3层设计开发一个ASP.NET应用程序,这是一个

场景:

如果有一个People类定义如下,

class People

{

string ID;

string FirstName;

string LastName;

string Address;

string Tel;

}


然后有2个webform页面,一个只显示ID,FirstName和

LastName属性

人物对象但另一个一个将显示所有属性。


Q1:两个webform页面都可以使用相同的People对象,或者我应该

创建并声明两个
每个网页表单的
类如下?哪一个更好维护

和性能?



您是否要在回发之间缓存对象?一般来说,

我会说不。也许是为个人用户缓存。在应用程序范围内缓存,

一般没有。我想如果数据是相对静态的(例如美国国家/地区的b $ b状态列表),您可以,但不是人类。至少,提供一种方式

来刷新缓存的对象,特别是在调试过程中。


class BasePeople

{

string ID;

string FirstName;

string LastName;

}


class人物:BasePeople

{

string地址;

string电话;

}


Q2:数据层应该读取db中的所有列和Biz Logic

图层选择必填字段

填写People对象?

或数据层只在一开始从db中获取所需的列?



我们有默认负载在设计时配置的字段。如有必要,他们可以在运行时覆盖
。 DAL生成动态SQL,

只返回将要加载的字段。


news.microsoft.com写道:


我正在尝试使用OO + 3层设计开发一个ASP.NET应用程序,这是一个

场景:

如果有一个People类定义如下,

class People

{

string ID;

string FirstName;

string LastName;

string Address;

string Tel;

}


然后有2个webform页面,一个只显示ID,FirstName和

LastName属性

People对象但是另一个将显示所有属性。


Q1:两个webform页面都可以使用相同的People对象,或者我应该创建

并声明两个
类如下?哪一个更好维护

和性能?


类BasePeople

{

字符串ID ;

string FirstName;

string LastName;

}


class人物:BasePeople

{

字符串地址;

字符串电话;

}



课程结构与建模有关。


企业是否区分只有基本信息的人和有地址和电话号码的人b $ b?br />

如果没有,那么我会说一个类。


Q2:数据层应该读取db和Biz的所有列逻辑

图层选择必填字段

填写People对象?

或数据层只在开始时从db中获取所需的列?



如果数据在一个表中并且没有LOB',那么一次获取所有数据




Arne




" Arne Vajh?j" < ar ** @ vajhoej.dkwrote in message

news:47 *********************** @ news.sunsite。 dk ...


news.microsoft.com写道:


>我正在尝试使用OO + 3层设计开发ASP.NET应用程序,这是一个
场景:
如果有一个People类定义如下,
类人物
{
字符串ID;
字符串FirstName;
字符串LastName;
字符串地址;
字符串电话;
}

然后有两个webform页面,一个只显示ID对象,FirstName和
LastName属性
People对象,但另一个将显示所有属性。

Q1:两者都是webform页面可以使用相同的People对象,或者我应该为每个webform页面创建和声明两个
类,如下所示?哪一个更好的维护和性能?

类BasePeople
{
字符串ID;
字符串FirstName;
字符串LastName; <课程人员:BasePeople
{
字符串地址;
字符串电话;
}



类结构是关于建模的。


业务是否区分具有基本信息的人和具有地址和电话号码的人b $ b?


如果没有,那么我会说一节课。



不,只显示表示层中的全部或部分信息。


>


> Q2:数据层应该读取db中的所有列,并且Biz Logic
层选择必填字段以填写人物对象?
或数据层只从头开始从db中获取所需的列?



如果数据在一个表中且没有LOB',那么一次获取所有数据




Arne



你的意思是在数据层中一次加载所有数据,如果我只需要ID /名称

某个页面中的属性,然后我应该将所有数据填入人们中b / b
pbject

或者只需填写ID / name属性,但保留其他属性为null在

商务层?



I''m trying to develop a ASP.NET app with OO + 3-tier design, here is a
scenario:
if there is a People class which is defined as below,
class People
{
string ID;
string FirstName;
string LastName;
string Address;
string Tel;
}

Then there are 2 webform page, one will display only ID,FirstName and
LastName properties of
the People object but another one will display all the properties.

Q1: both the two webform pages can use same People object or I should create
and declare two
classes as below for each webform page? which one is better on maintenance
and performance?

class BasePeople
{
string ID;
string FirstName;
string LastName;
}

class People: BasePeople
{
string Address;
string Tel;
}

Q2: The Data layer should read all the columns from db and the Biz Logic
layer selects required fields to
fill in the People object?
or the data layer only fetches required columns from db in the beginning?

Thanks in advance.

解决方案


"news.microsoft.com" <re*****@u.s.awrote in message
news:u9**************@TK2MSFTNGP05.phx.gbl...

I''m trying to develop a ASP.NET app with OO + 3-tier design, here is a
scenario:
if there is a People class which is defined as below,
class People
{
string ID;
string FirstName;
string LastName;
string Address;
string Tel;
}

Then there are 2 webform page, one will display only ID,FirstName and
LastName properties of
the People object but another one will display all the properties.

Q1: both the two webform pages can use same People object or I should
create and declare two
classes as below for each webform page? which one is better on maintenance
and performance?

Are you asking if you should cache the object across postbacks? In general,
I''d say no. Caching for an individual user, maybe. Caching application-wide,
generally no. I guess if the data is relatively static (e.g. a list of US
States) you could, but not a People class. At the very least, provide a way
to "refresh" the cached object, especially during debugging.

class BasePeople
{
string ID;
string FirstName;
string LastName;
}

class People: BasePeople
{
string Address;
string Tel;
}

Q2: The Data layer should read all the columns from db and the Biz Logic
layer selects required fields to
fill in the People object?
or the data layer only fetches required columns from db in the beginning?

We have "default load" fields that are configured at design-time. They can
be overridden at run-time if necessary. The DAL generates dynamic SQL that
only returns the fields that will be loaded.


news.microsoft.com wrote:

I''m trying to develop a ASP.NET app with OO + 3-tier design, here is a
scenario:
if there is a People class which is defined as below,
class People
{
string ID;
string FirstName;
string LastName;
string Address;
string Tel;
}

Then there are 2 webform page, one will display only ID,FirstName and
LastName properties of
the People object but another one will display all the properties.

Q1: both the two webform pages can use same People object or I should create
and declare two
classes as below for each webform page? which one is better on maintenance
and performance?

class BasePeople
{
string ID;
string FirstName;
string LastName;
}

class People: BasePeople
{
string Address;
string Tel;
}

Class structure is about modeling.

Does the business distinguish between people with just base info and
people with address and telephone number ?

If no then I would say one class.

Q2: The Data layer should read all the columns from db and the Biz Logic
layer selects required fields to
fill in the People object?
or the data layer only fetches required columns from db in the beginning?

If data is in one table and there are no LOB''s, then get all the data
at once.

Arne



"Arne Vajh?j" <ar**@vajhoej.dkwrote in message
news:47***********************@news.sunsite.dk...

news.microsoft.com wrote:

>I''m trying to develop a ASP.NET app with OO + 3-tier design, here is a
scenario:
if there is a People class which is defined as below,
class People
{
string ID;
string FirstName;
string LastName;
string Address;
string Tel;
}

Then there are 2 webform page, one will display only ID,FirstName and
LastName properties of
the People object but another one will display all the properties.

Q1: both the two webform pages can use same People object or I should
create and declare two
classes as below for each webform page? which one is better on
maintenance and performance?

class BasePeople
{
string ID;
string FirstName;
string LastName;
}

class People: BasePeople
{
string Address;
string Tel;
}


Class structure is about modeling.

Does the business distinguish between people with just base info and
people with address and telephone number ?

If no then I would say one class.

No, just display whole or partial information in presentation layer.

>

>Q2: The Data layer should read all the columns from db and the Biz Logic
layer selects required fields to
fill in the People object?
or the data layer only fetches required columns from db in the beginning?


If data is in one table and there are no LOB''s, then get all the data
at once.

Arne

You mean loading all the data at once in Data layer, if I only need ID/Names
properties in certain page, then I should fill in all data into the people
pbject
or just fill in the ID/name properties but keep other properties as null in
Biz layer?



这篇关于OO + 3层设计问:的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆