Relationships between entities

Chris Morley <[email protected]>
Newsgroups gmane.comp.programming.domain-driven-design
Message-ID <CAFhJrr7VujdvrANpKPNk7eRn16uJxx-Pz3JGMWnpJeAwKhXZXw@mail.gmail.com>
Dear all, I am creating a check out process, one step of which involves
configuring a product. I am currently tackling how best to structure this
on my domain model. The use cases are as follows:
*Product configuration*

A product configuration is a set of configurable option groups.
Option Group

Each option group can consist of one selected option (or none), an the
group consists of multiple options.

A user can add and remove options from a product group.

As an example, an option group may be called Databases.
Option

An option is a specific option of an option group.

As an example in the case of options belonging to the database option
group, specific options may be MySQL, or MS-SQL.
Option Group Dependency

Option groups can have a dependency on one other option group, so that
specific items are filtered out should the requirement on the target option
group not be met.

There is only one target dependency, we don't need to worry about options
in a product option group pointing to more than one target product option
group.

For example, in order to allow the MS-SQL option to be selected in the
database product group, the Windows option must be selected from the
Operating System option group.

Similarly, in order to allow the MySQL option to be selected on the
database product group, either Windows or Linux options must be selected
from the Operating System option group.
Structure

[image: mapping]<http://www.learnddd.com/wp-content/uploads/2013/11/mapping.png>

In the above diagram, the MySQL (ID = 201) product option has a dependency
on Windows (ID = 101) or Linux (ID = 102) product options of the OS product
option group. If either of these operating system options are selected,
then MySQL is shown.

The MS-SQL (ID = 202) product option has a dependency on Windows (ID = 101)
product option of the OS product option group. Only when Windows operating
system is selected will MS-SQL be shown.
Where to store the dependency mapping data?

The question for now as the code evolves, is where to store the
relationship dependency mapping between product options and their
groups. The main issues I am questioning are:

1) Where is it best to store the dependency mapping, in the
ProductOptionGroup, or external to this?

2) How do we structure the code so that in the above diagram as an example,
if there is a dependency on the operating system Windows, we protect it and
not allow removal from the OS ProductOptionGroup if other OptionGroups have
dependencies on it.

I had thought about making the OptionGroups hierarchical, but not sure if
that is wise in terms of database back-end, which whilst isn't a concern at
the moment, at some point the persistence repository will need to be
written and I don't want it coming back to haunt me - at least my gut
feeling is that hierarchical objects seem too involved at this time.

Any more experienced eyes who can comment on the above please? I have
copied from my blog
http://www.learnddd.com/product-configuration-relationships/

Thanks in advance,

Chris
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.