我应该共享使用公共字段的对象的 UI 吗?
我有一个父类,它包含所有设备类型之间通用的所有字段。由此,我有一些派生类,每个类都有其独特的字段。假设我的设备类型为“Switch”和“Transformer”。两个派生类都只有 2-3 个自己的唯一字段。在这种情况下进行 UI 设计(Windows 窗体)时。
我应该为每种设备类型创建两个单独的表单,还是创建一个包含所有设备之间共享的所有字段的用户控件?
谢谢。
I have a parent class that holds all of the fields that are common between all device types. From that, I have a few derived classes that each hold their unique fields. Say I have device type "Switch" and "Transformer". Both derived classes only have 2-3 of their own unique fields. When doing the UI design (windows forms) in this case.
Should I create two separate forms for each device type or create a user control with all fields that are shared among all devices?
Thank you.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
创建用户控件。您可以继承此用户控件以便向其添加字段,但由于子控件将共享属性和行为,因此它们应从公共父控件继承。
OOD 应该有助于防止代码重复。
Create a user control. You could inherit from this user control in order to add fields to it but as the child controls will share properties and behaviour they should inherit from a common parent.
OOD should help prevent code duplication.
我想说,就像在业务逻辑层中一样,您也可以在表示层中自由地使用 OOP 原则(在本例中为继承)。
I would say as in your business logic layer, you can freely use OOP principles (inheritance in this case) also in your presentation layer.