10. Tell Don’t Ask
public class Journey
{
…
public void AssociateRevenueInspectionTap(Tap tap) {..};
public void CounterZeroRateDueToRevenueProtection() {..};
…
}
11. Tell Don’t Ask?
public class Journey : Entity<Journey, JourneyKey>, IComparable<Journey>, IComparable<Tap>,
ITapSequence, ICanProtectRevenue, IJourneyAffectedByRevenueInspection, IMayNotExist,
IHaveTravelDayKey, IRateable, IDisruptable
{
…
public void AssociateRevenueInspectionTap(Tap tap) {..};
public void CounterZeroRateDueToRevenueProtection() {..};
public bool IsCounteredBy(Tap candidate) {..};
public bool Exists { get; }
public bool ContainsRevenueInspectionTap { get; }
…
}
16. public sealed class IsTapTypeRailInspection : Specification<Tap>
{
private static readonly ISpecification<Tap> _compositeSpecification =
new IsTapModeRail().And(new IsTapTypeRevenueInspection());
protected override bool IsSatisfiedBy(Tap candidate)
{
return _compositeSpecification.IsSatisfiedBy(candidate);
}
}
17. “Small Is Beautiful”
• E. F. Schumacher
• To counter Bigger is Better
• Empowers developers to build complex features
through small lego pieces
• Easy to read
18. Aggregate
“Nothing outside the Aggregate boundary can
hold a reference to anything inside, except to
the root entity…”
- Eric Evans, Domain Driven Design, 2004
20. Pipelines and decorators
public interface ICardOperation
{
Card Process(Card card);
}
public interface IDecoratedCardOperation
{
ICardOperation InnerCardOperation { get; private set; }
}
public class RevenueProtection : ICardOperation, IDecoratedCardOperation
{
public RevenueProtection (...)
{
...
}
public Card Process (Card card)
{
card = InnerCardOperation.Process (card);
...
return card;
}
public ICardOperation InnerCardOperation { get;set;}
}
21. Summary
• Abstractions rot code
• Small interfaces
• If you have a DTO reconsider your approach
• Even anaemic models can be encapsulated
• Immutability is your friend
22. Future?
• Token based software system
• Anything can create a token
• Vehicle registration plate
• Phone / wearable
• APIs (dog fooding with mobile)
• Data, data, data…