5

I've got a value type called "Product Type" that is assigned to a product. (A product has one product type)

To allow the user to select the type from a list, I'm going to fill a dropdown. Where is it most appropriate to retrieve the list of product types? A class implementing a repository pattern?

Edit: Clarified by changing product code to product type. A product type is something like "DVD"/"CD"/"Blu Ray"/etc.

Steve Horn
  • 8,818
  • 11
  • 45
  • 60
  • Do you want to create a list of product codes for all existing products? – Daniel Brückner May 23 '09 at 12:59
  • @Daniel Not necessarily. There may be no existing products. I'm just interested in the pattern I should be using to grab the list of product codes (value objects) from the database. – Steve Horn May 23 '09 at 13:02
  • The repository pattern seems a resonable choice for that. Are you thinking about it because of entity vs. value? – Daniel Brückner May 23 '09 at 13:15
  • 1
    @Daniel Indeed. It seems odd to have a repository for a value type. Plus, I have read that repositories should return entities only. – Steve Horn May 23 '09 at 13:20
  • I would not consider the product type a value type. Think of the departments of a company - even if you just use the department name to cluster employees, it is quite obviouse that it usualy should be a first class entity. Maybe it will be extended. Maybe not. But I would really consider a product type not less an entity than a department. – Daniel Brückner May 23 '09 at 13:31
  • @Daniel Lets just say for the purpose of this discussion that in my domain product type is a value object in the context of DDD. – Steve Horn May 23 '09 at 13:47
  • In this case I would handle it just like an enum - in C# it is a static method of the type like MyEnum.GetValues(). It's just a value type - no need to add extra classes and stuff. – Daniel Brückner May 23 '09 at 14:11

1 Answers1

6

Product seems to be aggregate root, so list of product types should be in ProductRepository.

Marek Tihkan
  • 1,914
  • 13
  • 11