ed blackburn ndc

Download Ed Blackburn NDC

Post on 18-Feb-2017

26 views

Category:

Documents

0 download

Embed Size (px)

TRANSCRIPT

Ed BlackburnFreelance Developer@ejblackburnhttp://ejb.name

Oyster CardJuly 2003 Oyster Card" by Frank Murmann is licensed under CC BY3.0

Contactless2014

Prove it

ComponentsIdentity ManagementCustomer ServicesCustomer PortalPayment and Risk ServicesCanonical, versioned reference dataPath finding fare generation for routesJourney Construction, apportionment, capping and fares

Behaviour Relativity" by M. C. Escheris, 1953

Evolving the MVPRevenue ProtectionDisruptionsTravel Products (Weekly, Monthly, Annual)

PhilosophyObject-Orientation; an object has both state (data) and behaviour (logic)Domain model focusedTell dont askSOLID

Tell Dont Askhttps://pragprog.com/articles/tell-dont-ask

Tell Dont Askpublic class Journey{public void AssociateRevenueInspectionTap(Tap tap) {..};public void CounterZeroRateDueToRevenueProtection() {..};}

Tell Dont Ask?public class Journey : Entity, IComparable, IComparable, 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; }}

internal IRule CreateRule(TravelDay travelDay){// Create rulesreturn Rule.Create(..);}

private IRule CreateRule(TravelDay travelDay){// Create rulesreturn Rule.Create(specification: new IsRITWithinPreviousJourney(travelDay),ifSatisfied: ScenarioT01,ifNotSatisfied: Rule.Create(..));}

private IRule CreateRule(TravelDay travelDay){// Create rulesreturn Rule.Create(specification: new IsRITWithinPreviousJourney(travelDay),ifSatisfied: ScenarioT01,ifNotSatisfied: Rule.Create( specification: new IsPreviousJourneyDisrupted(travelDay), ifSatisfied: ScenarioTDIS01, ifNotSatisfied: ScenarioT02 ));}

public sealed class IsTapTypeRailInspection : Specification{private static readonly ISpecification _compositeSpecification = new IsTapModeRail().And(new IsTapTypeRevenueInspection());

protected override bool IsSatisfiedBy(Tap candidate) { return _compositeSpecification.IsSatisfiedBy(candidate);}}

Small Is BeautifulE. F. SchumacherTo counter Bigger is BetterEmpowers developers to build complex features through small lego piecesEasy to read

AggregateNothing outside the Aggregate boundary can hold a reference to anything inside, except to the root entity

- Eric Evans, Domain Driven Design, 2004

Aggregates & Continuations?public class Card : Entity {

public void PerformCommand(IRuleCommand command) { PerformCommand(command, () => _journeys.Select(item => ) }

private void PerformCommand(IRuleCommand command, Func getEntities) { Rule.Create(command).Process(getEntities()); }}

Pipelines and decoratorspublic 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;}}

SummaryAbstractions rot codeSmall interfacesIf you have a DTO reconsider your approachEven anaemic models can be encapsulated Immutability is your friend

Future?Token based software systemAnything can create a tokenVehicle registration platePhone / wearableAPIs (dog fooding with mobile)Data, data, data