views:

52

answers:

1

I have class called 'Tool'. Tool has properties like: Name, Description and some specific others. Tool is special because Name and others are read only but description can be modified by users.

Count of tools is constant and known at development time. It is not Value Object because I need to query them and show to users where they can update Description. So, it's kind of Entity but users can not create new Tools.

I'm looking for possibility to take Tool like this:

Tool.SomeGreatTool

where SomeGreatTool is Tool with name "Some great tool" and description should be the same like this specified by user.

Jimmy Bogard has solution almost perfect but NHibernate know anything about SomeGreatTool and Description will be null.

How to modify Jimmy's solution or how to do it different way? How to instantiate SomeGreatTool from database?

+1  A: 

We still treat these kinds of semi-constant data as a sort of well-known entities. We create value objects/enumeration classes for the tool types, but separate tool types from tools. You still need to go to the persistent store to do something like ToolRepository.Find(ToolType.Screwdriver). Even though there will be only one tool per tool type, you'd still separate these two concepts.

Jimmy Bogard
Thanks very much :)
dario-g