【发布时间】:2015-12-23 14:26:46
【问题描述】:
我的问题是我应该将counterbore(板上的凹孔)设为plate 的属性还是将counterbore 设为joint 的属性
我有以下工程分析程序的课程:
Plate
Bolt
Washer
Nut
Material
Coating
然后我有代表各种关节的类
TappedJoint (a joint were the bolt is threaded into the bottom plate) will have:
Plate topPlate
Plate bottomPlate
Bolt bolt
Washer topWasher
BoltedJoint
Plate topPlate
Plate bottomPlate
Bolt bolt
Nut nut
Washer topWasher
Washer bottomWasher
沉孔仅适用于topPlate,但我需要验证用户输入的板厚是否大于沉孔深度。我只是在bottomPlate 中将counterbore 设置为null,还是将counterbore 属性放在联合类中更好?或者也许我应该使用其他模式,例如子类?
我将涂层和材料作为属性添加到每个部分,因为它太冗长而无法添加到关节,即:
BoltedJoint
Plate topPlate
Plate bottomPlate
Coating topPlateTopSurface
Coating topPlateBottomSurface
Coating bottomPlateTopSurface ...etc
我可能可以让它适用于任何一种情况,但也许他们的设计更好?
【问题讨论】:
-
Plate 实例是否需要知道它自己的沉孔?实际上需要两个沉孔验证:底板应该没有沉孔。这似乎意味着一个 Plate 需要知道它是如何被用来知道要运行什么验证的。开始变得丑陋,即使有 TopPlate 和 BottomPlate 类。
-
我不认为,因为在联合实例中,每个对象都可以相互引用