Хабр Курсы для всех
РЕКЛАМА
Практикум, Хекслет, SkyPro, авторские курсы — собрали всех и попросили скидки. Осталось выбрать!
[RequiredResult]
enum PostBoostInteractionKeyDecodingError
{
InvalidKeyFormat,
MismatchingUser,
MismatchingIdentity,
}
...
interface IPostBoostInteractionKeyDecoder
{
Result<PostBoostInteractionSource, PostBoostInteractionKeyDecodingError> DecodeInteractionKey(EntityId<SimpleUserProfile> profileId, BoostTarget target, string interactionKey);
}
...
[RequiredResult]
public enum RegisterBoostedPostInteractionResult
{
Success,
MissingOrInactiveBoost,
AlreadyVisited,
PaymentFailed,
}
...
interface IPostBoostInteractionTracker
{
RegisterBoostedPostInteractionResult RegisterInteraction(EntityId<SimpleUserProfile> profileId, PostBoostInteractionSource source, PostBoostInteractionType type);
}
...
bool RegisterInteraction(string interactionKey, EntityId<SimpleUserProfile> profileId, BoostTarget target, PostBoostInteractionType interactionType)
=> _interactionKeyDecoder.DecodeInteractionKey(profileId, target, interactionKey)
.And(source => _interactionTracker.RegisterInteraction(profileId, source, interactionType))
.And(registerResult => registerResult == RegisterBoostedPostInteractionResult.Success)
.Unwrap(false);
EntityId свой не покажете? Хочется со своим сравнить.В плюсы ещё список всех Failure (как с checked exceptions).
Вот это я как раз в плюсы занести не могу — слишком уж жесткий получается контракт, причем за счет фиксации на побочных путях, имеющих не самое прямое отношение к основной решаемой задаче.
Кстати, на F# же вроде есть аналог do-нотации, почему бы не использовать его?
Кстати, на F# же вроде есть аналог do-нотации, почему бы не использовать его?
Железнодорожно-ориентированное программирование. Обработка ошибок в функциональном стиле