C#OO问题 [英] C# OO problem

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

问题描述

我为我的业务层创建了一系列类,数据检索是好的,但是b $ b工作得很好而且看起来不错。


但我很快就发现了我系统中的设计缺陷是我的

对象不知道兄弟姐妹和父母。

换句话说,如果我有一个Customer对象和Customer对象有

CustomerSettings对象 - 假设我想创建一个新客户,然后

根据CustomerSettings向新客户添加一组CustomerSettings

来自其他客户。我不能,至少不是优雅的。


我需要重新设计,以便我的对象有一个共同的成员,将公开

所有他们需要的其他数据。


由于客户是我BOL层次结构中的理论顶级节点,

没有别的东西将它们捆绑在一起。


我试图决定如何解决这个问题,但是我很快就会出现问题。我认为

一个名为BOLDataManager的新顶级对象将持有客户和他们的孩子将是一个很好的解决方案,但是我仍然面临着

了解BOLDataManager的Customer对象的问题。每次添加客户时,我都会将

引用传递给它的实例吗?那似乎没什么。

正确。


我希望这对某人有意义,我很困难,我很乐意

找到一个好的解决方案并继续前进!


谢谢,

史蒂夫

I have created a series of classes for my business layer, data retrieval is
working fine and things seem good.

However I have quickly discovered a design flaw in my system in that my
objects aren''t aware of siblings and parents.
In other words, if I have a Customer object and Customer objects have
CustomerSettings objects - Let''s say I want to create a new Customer, then
add a set of CustomerSettings to the new customer based on CustomerSettings
from another Customer. I can''t, not gracefully at least.

I need to re-design so that my objects have a common member that will expose
all the other data they need.

Since Customers are the theoretical top level node in my BOL hierarchy,
there is nothing else tying them together.

I have tried to decide how to solve this, but am coming up short. I thought
that a new, top level object called BOLDataManager that would hold Customers
and their children would be a good solution, but then I''m still faced with
the issue of the Customer objects knowing about BOLDataManager. Do I pass a
reference to it''s instance everytime I add a Customer? That doesn''t seem
correct.

I hope this makes sense to someone, I''m pretty stuck and I would love to
find a good solution and move on!

Thanks,
Steve

推荐答案

史蒂夫,


我很好奇,为什么不公开客户的子业务对象集合?b $ b?您将在Customer上拥有一个名为Settings的属性,

将公开CustomerSettings对象集合。


当然,这需要你走在你的heiarchy中数据

图层,但它不应该是一个很大的问题。


希望这会有所帮助。

-

- Nicholas Paldino [.NET / C#MVP]

- mv * @ spam .guard.caspershouse.com


" sklett" <关于** @ fkd.com>在留言中写道

新闻:我们**************** @ TK2MSFTNGP15.phx.gbl ...
Steve,

I am curious, why not just expose a collection of sub-business objects
from Customer? You would have a property on Customer called Settings which
would expose the CustomerSettings object collection.

Of course, this would require you to walk the heiarchy in your data
layer, but it shouldn''t be that much of a problem.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"sklett" <as**@fkd.com> wrote in message
news:us****************@TK2MSFTNGP15.phx.gbl...
我创建了我的业务层的一系列类,数据检索工作正常,事情似乎很好。

然而,我很快发现了我的系统中的一个设计缺陷,即我的
对象不知道兄弟姐妹和父母。
换句话说,如果我有一个Customer对象而Customer对象有CustomerSettings对象 - 假设我想创建一个新客户,那么
根据来自其他客户的CustomerSettings向新客户添加一组CustomerSettings。我不能,至少不是优雅的。

我需要重新设计,以便我的对象有一个共同的成员,可以公开他们需要的所有其他数据。

由于客户是我BOL层次结构中的理论顶级节点,
没有别的东西将它们捆绑在一起。

我试图决定如何解决这个问题,但是我即将到来。我认为一个名为BOLDataManager的新顶级对象可以容纳顾客和他们的孩子,这将是一个很好的解决方案,但是我仍然面对客户的问题了解BOLDataManager的对象。
每次添加客户时,是否都会将引用传递给它的实例?
看起来并不正确。

我希望这对某人有意义,我很困难,我很乐意找到一个好的解决方案并继续前进!

谢谢,
史蒂夫
I have created a series of classes for my business layer, data retrieval is
working fine and things seem good.

However I have quickly discovered a design flaw in my system in that my
objects aren''t aware of siblings and parents.
In other words, if I have a Customer object and Customer objects have
CustomerSettings objects - Let''s say I want to create a new Customer, then
add a set of CustomerSettings to the new customer based on
CustomerSettings from another Customer. I can''t, not gracefully at least.

I need to re-design so that my objects have a common member that will
expose all the other data they need.

Since Customers are the theoretical top level node in my BOL hierarchy,
there is nothing else tying them together.

I have tried to decide how to solve this, but am coming up short. I
thought that a new, top level object called BOLDataManager that would hold
Customers and their children would be a good solution, but then I''m still
faced with the issue of the Customer objects knowing about BOLDataManager.
Do I pass a reference to it''s instance everytime I add a Customer? That
doesn''t seem correct.

I hope this makes sense to someone, I''m pretty stuck and I would love to
find a good solution and move on!

Thanks,
Steve



嗨尼古拉斯,

我想我不清楚。我的客户对象上有属性暴露

嵌套对象和集合,但问题是2个客户

对象彼此不了解。 />

如果我在顾客的方法中叫做AddSettingsFromTemplateCustomer(字符串

templateName)(长名,呵呵?)

和我想找到名字为[templateName]的客户我不能,因为我的客户对象与其他客户隔离了。

我希望能赚到更多感。感谢您的回复,当我看到

a回复显示时,我很兴奋;)

Steve


Nicholas Paldino [。 NET / C#MVP]" < mv*@spam.guard.caspershouse.com>写在

消息新闻:Ov ************** @ TK2MSFTNGP14.phx.gbl ...
Hi Nicholas,

I think I was unclear. I do have properties on my Customer objects exposing
the nesting objects and collections, but the problem is that 2 Customer
objects aren''t aware of each other.

If I''m in a method of Customer called AddSettingsFromTemplateCustomer(string
templateName) (long name, huh?)
and I wanted to find the customer that had the name [templateName] I can''t,
because my customer object is isolated from the others.
I hope that makes more sense. Thanks for replying, I get excited when I see
a reply show up ;)
Steve

"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote in
message news:Ov**************@TK2MSFTNGP14.phx.gbl...
Steve,
我很好奇,为什么不从客户那里公开一系列子业务对象?您将在Customer上拥有一个名为Settings
的属性,它将公开CustomerSettings对象集合。

当然,这需要您在数据层中使用heiarchy,但是它不应该是一个很大的问题。

希望这会有所帮助。

-
- Nicholas Paldino [.NET / C#MVP]
- mv*@spam.guard.caspershouse.com

sklett <关于** @ fkd.com>在消息中写道
新闻:我们**************** @ TK2MSFTNGP15.phx.gbl ...
Steve,

I am curious, why not just expose a collection of sub-business objects
from Customer? You would have a property on Customer called Settings
which would expose the CustomerSettings object collection.

Of course, this would require you to walk the heiarchy in your data
layer, but it shouldn''t be that much of a problem.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"sklett" <as**@fkd.com> wrote in message
news:us****************@TK2MSFTNGP15.phx.gbl...
我创建了一系列课程对于我的业务层,数据检索工作正常,事情似乎很好。

然而,我很快发现我的系统存在设计缺陷,因为我的
对象不是知道兄弟姐妹和父母。
换句话说,如果我有一个Customer对象,而Customer对象有CustomerSettings对象 - 假设我想创建一个新客户,那么添加基于来自其他客户的CustomerSettings向新客户提供一组CustomerSettings。我不能,不能优雅地至少。

我需要重新设计,以便我的对象有一个共同的成员,将公开他们需要的所有其他数据。

由于客户是我BOL层次结构中的理论顶级节点,
没有别的东西将它们捆绑在一起。

我试图决定如何解决这个,但我很快就会出现。我认为,一个名为BOLDataManager的新顶级对象能够吸引顾客及其子女,这将是一个很好的解决方案,但是我仍然面对客户的问题了解BOLDataManager的对象。每次添加
客户时,我都会将参考文件传递给它吗?这看起来并不正确。

我希望这对某人有意义,我很困难,我很乐意找到一个好的解决方案并继续前进!

谢谢,
Steve
I have created a series of classes for my business layer, data retrieval
is working fine and things seem good.

However I have quickly discovered a design flaw in my system in that my
objects aren''t aware of siblings and parents.
In other words, if I have a Customer object and Customer objects have
CustomerSettings objects - Let''s say I want to create a new Customer,
then add a set of CustomerSettings to the new customer based on
CustomerSettings from another Customer. I can''t, not gracefully at
least.

I need to re-design so that my objects have a common member that will
expose all the other data they need.

Since Customers are the theoretical top level node in my BOL hierarchy,
there is nothing else tying them together.

I have tried to decide how to solve this, but am coming up short. I
thought that a new, top level object called BOLDataManager that would
hold Customers and their children would be a good solution, but then I''m
still faced with the issue of the Customer objects knowing about
BOLDataManager. Do I pass a reference to it''s instance everytime I add a
Customer? That doesn''t seem correct.

I hope this makes sense to someone, I''m pretty stuck and I would love to
find a good solution and move on!

Thanks,
Steve




Steve,


在这种情况下,你必须要有某种经理(我会将b $ b私有化),这将在名称和

之间有一个映射。实例本身。


这个问题是管理员会延长对象的生命周期

。您将不得不添加额外的代码来指示对象

何时被使用,以便经理可以释放它。

-

- Nicholas Paldino [.NET / C#MVP]

- mv*@spam.guard.caspershouse.com


" sklett" <关于** @ fkd.com>写在消息

新闻:%2 **************** @ TK2MSFTNGP12.phx.gbl ...
Steve,

In that case, you would have to have a manager of some sort (I would
make it private) which would have a mapping between the name and the
instance itself.

The problem with this is that the manager would extend the lifetime of
the object. You would have to add extra code to indicate when the object
was done being used, so that the manager could release it.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"sklett" <as**@fkd.com> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
嗨尼古拉斯,

我想我不清楚。我的客户对象上有属性
暴露嵌套对象和集合,但问题是2
客户对象彼此之间并不了解。

如果我'在客户的方法中叫做AddSettingsFromTemplateCustomer(string templateName)(长名,呵呵?)
我希望找到名字为[templateName]的客户我可以'不,因为我的客户对象与其他人隔离了。

我希望这更有意义。感谢您的回复,当我看到回复显示时,我感到很兴奋;)
史蒂夫

Nicholas Paldino [.NET / C#MVP]" < mv*@spam.guard.caspershouse.com>在消息新闻中写道
:Ov ************** @ TK2MSFTNGP14.phx.gbl ...
Hi Nicholas,

I think I was unclear. I do have properties on my Customer objects
exposing the nesting objects and collections, but the problem is that 2
Customer objects aren''t aware of each other.

If I''m in a method of Customer called
AddSettingsFromTemplateCustomer(string templateName) (long name, huh?)
and I wanted to find the customer that had the name [templateName] I
can''t, because my customer object is isolated from the others.
I hope that makes more sense. Thanks for replying, I get excited when I
see a reply show up ;)
Steve

"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote
in message news:Ov**************@TK2MSFTNGP14.phx.gbl...
Steve,
我很好奇,为什么不从客户那里公开一系列子业务对象?您将在Customer上拥有一个名为Settings
的属性,它将公开CustomerSettings对象集合。

当然,这需要您在数据层中使用heiarchy,但是它不应该是一个很大的问题。

希望这会有所帮助。

-
- Nicholas Paldino [.NET / C#MVP]
- mv*@spam.guard.caspershouse.com

sklett <关于** @ fkd.com>在消息中写道
新闻:我们**************** @ TK2MSFTNGP15.phx.gbl ...
Steve,

I am curious, why not just expose a collection of sub-business objects
from Customer? You would have a property on Customer called Settings
which would expose the CustomerSettings object collection.

Of course, this would require you to walk the heiarchy in your data
layer, but it shouldn''t be that much of a problem.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"sklett" <as**@fkd.com> wrote in message
news:us****************@TK2MSFTNGP15.phx.gbl...
我创建了一系列课程对于我的业务层,数据检索工作正常,事情似乎很好。

然而,我很快发现我的系统存在设计缺陷,因为我的
对象不是知道兄弟姐妹和父母。
换句话说,如果我有一个Customer对象,而Customer对象有CustomerSettings对象 - 假设我想创建一个新客户,那么添加基于来自其他客户的CustomerSettings向新客户提供一组CustomerSettings。我不能,不能优雅地至少。

我需要重新设计,以便我的对象有一个共同的成员,将公开他们需要的所有其他数据。

由于客户是我BOL层次结构中的理论顶级节点,
没有别的东西将它们捆绑在一起。

我试图决定如何解决这个,但我很快就会出现。我认为,一个名为BOLDataManager的新顶级对象能够吸引顾客及其子女,这将是一个很好的解决方案,但是我仍然面对客户的问题了解BOLDataManager的对象。每次添加
客户时,我都会将参考文件传递给它吗?这看起来并不正确。

我希望这对某人有意义,我很困难,我很乐意找到一个好的解决方案并继续前进!

谢谢,
Steve
I have created a series of classes for my business layer, data retrieval
is working fine and things seem good.

However I have quickly discovered a design flaw in my system in that my
objects aren''t aware of siblings and parents.
In other words, if I have a Customer object and Customer objects have
CustomerSettings objects - Let''s say I want to create a new Customer,
then add a set of CustomerSettings to the new customer based on
CustomerSettings from another Customer. I can''t, not gracefully at
least.

I need to re-design so that my objects have a common member that will
expose all the other data they need.

Since Customers are the theoretical top level node in my BOL hierarchy,
there is nothing else tying them together.

I have tried to decide how to solve this, but am coming up short. I
thought that a new, top level object called BOLDataManager that would
hold Customers and their children would be a good solution, but then I''m
still faced with the issue of the Customer objects knowing about
BOLDataManager. Do I pass a reference to it''s instance everytime I add a
Customer? That doesn''t seem correct.

I hope this makes sense to someone, I''m pretty stuck and I would love to
find a good solution and move on!

Thanks,
Steve





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

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