If I have a custom type (or maybe an enum) like for ex. a Range
:
Public Class Range
Sub New(minimum As Single, maximum As Single)
Me.Minimum = minimum
Me.Maximum = maximum
End Sub
Public Property Minimum As Single
Public Property Maximum As Single
Public ReadOnly Property Delta As Single
Get
Return Maximum - Minimum
End Get
End Property
End Class
'-----------
'Some methods...
This type should be used in the domain model(implementing DDD), in the business logic when doing stuff and also in the data layer, where it will be stored as a complex type.
So :
- should I define such classes in a Project
App.Common
and reference this assembly everywhere (my choice for now, but don't know if having references in domain model project is an anti-pattern?) - should I define it in my domain model and reference my domain model everywhere where it is needed. (maybe better? since Domain model is core in DDD, but the type is not a domain or value object...)
- should I create different classes for each layer (which don't make sense to me, since I want to handle it like another type and not as Object)?
EDIT
In my case I use range
as a MeasuringRange
for measure devices. For ex. a thermometer that can measure from 0°F-250°F:
public class Thermometer
{
public Thermometer(Range measureRange)
{
this.MeasureRange=measureRange;
}
public Range MeasureRange {get;set;}
}
At the moment it's also used in the DataLayer (using EF Code First) to store the device range as a complexType (EF creates fields MeasureRange_Max
and MeasureRange_Min
.
It's also used in services in the BLL when doing some measurements with the devices.