Modeling related objects and their templates

Posted by Duddle on Stack Overflow See other posts from Stack Overflow or by Duddle
Published on 2010-05-13T16:43:34Z Indexed on 2010/05/13 21:54 UTC
Read the original article Hit count: 362

Hello everybody!

I am having trouble correctly modeling related objects that can use templates. This is not homework, but part of a small project in the university.

In this application the user can add several elements, which can either be passive or active. Each concrete element has different attributes, these must be set by the user. See diagram 1: diagram 1

Since the user will create many elements, we want there to be templates for each type of element, so some of the attributes are filled in automatically. See diagram 2: diagram 2

In my opinion, this is a bad design. For example, to get all possible templates for a PassiveElementA-object, there has to be a list/set somewhere that only holds PassiveElementATemplate-objects.

There has to be a separate list for each subclass of Element. So if you wanted to add a new PassiveElement-child, you also have to edit the class which holds all these separate lists.

I cannot figure out a good way to solve this problem. Since the concrete classes (i.e. PassiveElementA, ..., PassiveElementZ) have so many different attributes, many of the design patterns I know do not work.

Thanks in advance for any hints, and sorry for my bad English.

© Stack Overflow or respective owner

Related posts about uml

Related posts about uml-modeling