Can this object model for my Java application be improved?

I'm designing a Java application that will be used by contractors to diagram residences. Currently, I'm in the modeling phase and am creating a UML class diagram. My issue is that I'm not sure the ideal way to model some of my objects. Users will "draw" elements of the home like walls, lights, doors, windows, etc... Each element has an initial set of required properties. Based on this initial set of required properties, a sub set of different properties will be required for that element. I'll use my Structure class as an example. One of the things a user will "draw" on the diagram is a Structure. A structure's two main properties are structureType and composition. Composition is straightforward. The client provides a list of possible compositions that that a user will select, so I put that data in a combo box and let the pick from a drop down. However, based on structureType, additional properties will be required. IE) if StructureType = Wall, then length and height are required. If StructureType = Ceiling, then length, width and height are all required. The example is simplified and may seem trivial, but the sub-properties can get much more involved than this, and there are many of them. Some of them give rise to even further sub-properties. However, despite the over simplification, it gives a pretty specific idea of the problem I'm trying to solve. My thinking is that I should have subclasses extending Structure, each with a set of properties that are unique to each subclass. IE) class Wall extends class Structure, and contains a group of member variables unique to Walls. Some advice on wether or not I'm thinking about this clearly would be appreciated, and if I'm off base a push in the right direction would be appreciated. Likewise if there's a consideration I've missed in my decision making, some constructive criticism is welcome.
Your method makes total sense. Also consider using Properties objects.

以上就是Can this object model for my Java application be improved?的详细内容,更多请关注web前端其它相关文章!

赞(0) 打赏
未经允许不得转载:web前端首页 » JavaScript 答疑

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

前端开发相关广告投放 更专业 更精准