I often write code which translates entities in the database to domain objects. These entities often have fields which are constrained and translate to enumerations in the domain objects. In some cases, though, the fields can be null.
For example, imagine I have a
PrintJob entity with a
Status field that can be
Completed and a
Result field that can be
FailedNoToner but it can also be
NULL if the
Status is not
On the one hand, I like having a one-to-one mapping of entity field values to domain object enum values, but on the other hand, it somehow feels "better" to always have values for properties with enumeration types.
My question is: is it better to represent the value of the
Result field in my domain object as a nullable value (e.g.
MyStatus? in C# or VB.NET) having essentially no value when the corresponding entity field is
NULL, or should I create a special enum value along with the others, e.g.