Liquid-Application-Framework-1.0-deprecated
Liquid-Application-Framework-1.0-deprecated copied to clipboard
DomainResponse should expose a type safe payload
DomainResponse
has a PayLoad
property that represents the actual value of a business operation.
Currently, this property is of type JToken
, making it awkward to use as we always have to call the JToken.ToObject method.
https://github.com/Avanade/Liquid-Application-Framework/blob/93f7874f2ead13d3602cc39fc1e9355206217f57/src/Liquid.Domain/Base/Domain/DomainResponse.cs#L25-L28
In my opinion, DomainResponse
should have two versions: A base one, without the payload, and a second one with a type safe payload property:
//extra code removed for readability reasons
public class DomainResponse
{
public JToken Critics { get; set; }
}
public class DomainResponse<TPayload> : DomainResponse
{
public TPayload Payload { get; set; }
}
Why
- Not every business operation returns a value. Some of them just indicates if everything went right (e.g "Successfully saved")
- Relying on type safety is always beneficial as we can solve things at compile time, and also makes the code clearer to the developers
What to consider
- Since this would be a breaking change, maybe we should introduce a new class, considering that
DomainResponse
already has a couple of issues (#57, #54, #35)