我应该在 UML 中使用枚举或类构造型来表示类型目录表吗?
让我们采用 2 个 UML 类模型实体:一个代表实际的 Order,另一个代表 Orede 类型。任何订单对应一种类型。意味着一种类型关系的多个订单的 2 路导航。订单类型实例例如是“请求可用性”、“请求价格”、“预购”、“购买”、“取消”、“请求支持”等。订单类型可以在生成的应用程序中添加和编辑。我应该将订单类型建模为类还是枚举?从数据的角度来看,我实际上看不出差异。
Let's take 2 UML class model entities: One represents an actual Order and another represents an Orede Type. Any Order corresponds to one Type. A 2-way-naviglabe many Orders to one Type relation is meant. Order Type instances are, for example, "Request availability", "Request price", "Preorder", "Buy", "Cancel", "Request support", etc. Order Types are to be addable and editable in the resulting application. Should I model Order Type as Class or as Enumeration? From the data perspective I can't see the difference actually.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我更喜欢枚举。类应该定义属性和行为。在这种情况下,类型仅表示一个值,不需要方法。
结论:
如果您只想表示值,那么使用类肯定是可能的,但不是必需的。此外,它还会产生大量额外的编码工作。当您可以使用枚举时,您将不得不编写和维护一堆仅表示一个值的类,这无疑是表示类型化值的最佳且最短的方式。
I would prefer an enumeration. Classes should define properties and behaviour. In this case the type represents only a value with no need of methods.
Conclusion:
The usage of a class would surely possible but not necessary if you only want to represent values. Also, it would create a lot of extra coding work. You would have to write and maintain a bunch of classes that only represent one value when you could use an enumeration, which is surely the best and shortes way to represent typed values.