1

I have a problem regarding my current CodeBook.

CodeBook is an entity that consists of two attributes, the Code and Description. It is an abstract class. I extended that class with the Class Domain.
Domain class is also an abstract class and contains enum DomainType, which has values: e.g. NATIONALITY, NATIVE_LANGUAGE, DISEAS.. etc

Now I have to make "document" entities which will later be filled with data.

So for example, the client has to pick the nationality. It will select one from the list of the values that has been entered in the codebook DomainNationality (Extends Domain) for the domainType.NATIONALITY, BUT what if I don't have his nationality in my CodeBook? I will put an option OTHER, that he can select,but I also need to put the field where he will type his OTHER nationality.

How do I keep a record of that other nationality? Right now,my document entities has associative links to DomainNationality.DomainSex, DomainNativeLanguage etc.. Is the String field next to every domain in my document the best and easiest solution? I don't want to let clients enter new stuff in to the CodeBook.

Thank you!

oers
  • 18,436
  • 13
  • 66
  • 75
zevonja
  • 193
  • 1
  • 14

1 Answers1

0

This is mainly your design-decision. You can do it which-ever way you design your object-responsibilities. But here are my thoughts: Since you say it is possible that the client's nationality is not among those which you offer and want to offer him/her a field to enter a custom nationality you should just store the nationality as a string in the object (no enum). You can always check afterwards if the nationality of a client is among the pre-defined ones.

Bernd Elkemann
  • 23,242
  • 4
  • 37
  • 66