It annoys me that I am required to have them, for an example consider the case
public class IsEquipmentAvailable : Specification<Equipment>
{
public IsEquipmentAvailable() : base(equipment => equipment.CartEquipments
.All(o => o.RentState == RentState.Done))
}
However, I am not allowed to write this as I need to add {}
, in c# that is at least 2 extra lines of the boilerplate code that do nothing. If I want to support directed expression graph chain calls or just instantiating element from an expression, it becomes even worse.
public class IsEquipmentAvailable : Specification<Equipment>
{
public IsEquipmentAvailable(Expression<Func<Equipment, bool>> expression)
: base(expression)
{
}
public IsEquipmentAvailable(ISpecification<Equipment> specification)
: base(specification)
{
}
public IsEquipmentAvailable() : base(equipment => equipment.CartEquipments
.All(o => o.RentState == RentState.Done))
{
}
}
The functional programming side of me laughs from ignorance because he does not know better. Sometimes there are valid reasons why things are the way they are, so I would like to know reasoning behind this.