Skip to content

Domain Layer

Enis Ademov edited this page Aug 20, 2023 · 1 revision

Entity

 public class FriendReferral {

        public List<FriendReferralStep> Steps { get; private set; }

        public int CurrentProgress { get; set; }

        public FriendReferral(
            List<FriendReferralStep> steps,
            int currentProgress
        ) {
            Steps = steps;
            CurrentProgress = currentProgress;
        }

    }

Rules:

  1. Entities are mutable;
  2. Entities do not need to be serializable;
  3. The entity state should be encapsulated to external access. Usually Repository;
  4. Entities can contain methods, as long as they are encapsulated;
  5. Entities can enforce certain business rules;
  6. Entities can throw domain exceptions.

Repository Interface

    public interface IFriendReferralRepository {

        IObservable<Domain.FriendReferral.FriendReferral> GetFriendReferrals();

        Task ClaimFriendReferralBonus();

    }

Rules:

  1. Do no use void for Create/Update/Delete type of operations. Use Task instead, even if it's not async method.
Clone this wiki locally