0

Are there any tools out there that let you model how a class (or a class hierarchy) can change at runtime? For example, if I have a given number of mixin classes that will be combined at runtime and I don't know which ones will be combined until the program runs, how do you go about diagramming that type of runtime behavior?

Here's a better example. Let's say that I have a base class called IceCream, and I have over 100 possible flavors that all derive from that one IceCream class. Let's also suppose that any instance of the IceCream class can be combined with another instance of the IceCream class to create a completely unique IceCream type altogether. Given this domain, how do you use a graphical model to actually say that any one of these types can be combined at runtime?

It would be inefficient to model all the possible combinations of IceCream types, given that there can be a virtually infinite number of permuations for these 100 IceCream types. So again, here's the question: Are there any graphical modeling languages that let you specify this sort of behavior?

4

3 回答 3

1

你的设计听起来有点令人不安。如果两种不同的冰淇淋具有不同的行为,那么为什么对所有可能性进行建模是错误的呢?你从哪里加载行为?很可能是这种情况,但如果是这样,我猜你想包含这种行为......

如果他们没有不同的行为,那么你所说的只是一个带有“Flavor”成员的“IceCream”类。当唯一的区别是数据时,永远不要创建第二个类——代码在这两种情况下实际上必须不同,以保证不同的类。

如果我完全错过了什么,我道歉。

编辑:让我更具体地说明“包含行为”。如果您的每种冰淇淋口味都有一个“口味”(即代码),并且香草、草莓和巧克力之间的口味不同——那么您就有 3 个“口味”冰淇淋类别包含在一个“锥形”中班级。

我认为您正在尝试将 Cone 类建模为“IceCream”。由于锥体包含所有三个,“Lick”方法可以以任何可能的方式组合这三个。您可以 lick(bottom)、lick(middle) 或 lick(top),或者您可以只 lick() 并允许 lick 方法将所有三个组合到一个调用中(更真实的代码,您可以传递一个lick() 的单个变量,将转发给所有包含的风味)。

于 2009-07-01T23:44:13.140 回答
0

我想知道 Bento 或 DabbleDB 的个人数据库方法是否与实际建模部分相关。然后可能是 Django 管理员对逻辑部分的模型自省。听起来您想创建脚本语言的接口。一种 vpl 库。因此,一个增强的、更具反思性的 Django 管理员可能是一个起点。

于 2009-10-20T15:00:43.767 回答
0

一般来说,如果你想创建 UML 类图,你可以利用UML 中的泛型类型。此外,UML中还有模板参数的概念。

看看这个网站:使用 UML 模板定义泛型

他们使用Eclipse 建模框架作为工具。

于 2010-08-11T12:16:15.477 回答