对象实例的动态属性? [英] Dynamic Properties for object instances?

查看:114
本文介绍了对象实例的动态属性?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在上一个问题对象模型设计中的重要规则是什么"之后,现在我要提出以下问题:

After the previous question "What are the important rules in Object Model Design", now I want to ask this:

是否可以为类实例提供动态属性?

假设我们有这个原理图对象模型:

Suppose that we have this schematic object model:

因此,由于已实现的接口集,每个对象可能具有许多属性,然后成为相对较重的对象.创建所有可能的对象(当然是合理的对象)可以解决此问题(即Pipe_Designed相对于Pipe_Designed_NeedInspection),但是到目前为止,我有大量的接口,这很困难. 我想知道是否存在一种具有动态属性的方法,类似于以下对话框,该对话框允许最终用户为他/她的新对象选择可用的功能.

So, each object could have lots of properties due to the set of implemented Interfaces, and then become relatively heavy object. Creating all the possible -and of course reasonable- object can be a way for solving this problem (i.e. Pipe_Designed v.s. Pipe_Designed_NeedInspection), but I have a large number of interfaces by now, that make it difficult. I wonder if there is a way to have dynamic properties, something like the following dialog to allow the end user to select available functionalities for his/hers new object.

推荐答案

您想要的是Properties pattern.在史蒂夫·耶格(Steve Yegge)上查看这篇漫长而无聊的文章. /a>

What you want is Properties pattern. Check out long and boring but clever article from Steve Yegge on this

这篇关于对象实例的动态属性?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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