YOW West 2017 - YOW! Conference...YOW West 2017 OUR SPONSORS Cost of a dependency Trainer Dev at...

69
YOW West 2017 OUR SPONSORS

Transcript of YOW West 2017 - YOW! Conference...YOW West 2017 OUR SPONSORS Cost of a dependency Trainer Dev at...

Page 1: YOW West 2017 - YOW! Conference...YOW West 2017 OUR SPONSORS Cost of a dependency Trainer Dev at –CashiesPractical Rx Lee Campbell Author of eBook and website IntroToRx.com Conference

YOW West 2017OUR SPONSORS

Page 2: YOW West 2017 - YOW! Conference...YOW West 2017 OUR SPONSORS Cost of a dependency Trainer Dev at –CashiesPractical Rx Lee Campbell Author of eBook and website IntroToRx.com Conference

Cost of a dependency

Page 3: YOW West 2017 - YOW! Conference...YOW West 2017 OUR SPONSORS Cost of a dependency Trainer Dev at –CashiesPractical Rx Lee Campbell Author of eBook and website IntroToRx.com Conference

Dev at CashiesTrainer – Practical Rx

Lee CampbellAuthor of eBook and website IntroToRx.com Conference Circuit

Page 4: YOW West 2017 - YOW! Conference...YOW West 2017 OUR SPONSORS Cost of a dependency Trainer Dev at –CashiesPractical Rx Lee Campbell Author of eBook and website IntroToRx.com Conference

Project success

Page 5: YOW West 2017 - YOW! Conference...YOW West 2017 OUR SPONSORS Cost of a dependency Trainer Dev at –CashiesPractical Rx Lee Campbell Author of eBook and website IntroToRx.com Conference

LongevityHow long will your project need to be used for?

How long will it need to be maintained for?

How long will each of it’s dependent parts be relevant for?

Page 6: YOW West 2017 - YOW! Conference...YOW West 2017 OUR SPONSORS Cost of a dependency Trainer Dev at –CashiesPractical Rx Lee Campbell Author of eBook and website IntroToRx.com Conference

FreedomsSingle man dependencies vs Fungible assets

Technology lock-in vs Technology agnostic

Page 7: YOW West 2017 - YOW! Conference...YOW West 2017 OUR SPONSORS Cost of a dependency Trainer Dev at –CashiesPractical Rx Lee Campbell Author of eBook and website IntroToRx.com Conference

A case studyA COLLECTION OF EXPERIENCES

A case study

Page 8: YOW West 2017 - YOW! Conference...YOW West 2017 OUR SPONSORS Cost of a dependency Trainer Dev at –CashiesPractical Rx Lee Campbell Author of eBook and website IntroToRx.com Conference

How did it get like this?COMPOUNDING EFFECTS

Page 9: YOW West 2017 - YOW! Conference...YOW West 2017 OUR SPONSORS Cost of a dependency Trainer Dev at –CashiesPractical Rx Lee Campbell Author of eBook and website IntroToRx.com Conference

1. Single repo

Page 10: YOW West 2017 - YOW! Conference...YOW West 2017 OUR SPONSORS Cost of a dependency Trainer Dev at –CashiesPractical Rx Lee Campbell Author of eBook and website IntroToRx.com Conference

Single repo\GUI

\Server

\Datastore

Page 11: YOW West 2017 - YOW! Conference...YOW West 2017 OUR SPONSORS Cost of a dependency Trainer Dev at –CashiesPractical Rx Lee Campbell Author of eBook and website IntroToRx.com Conference

Single repo\GUI

◦ FeatureA

◦ FeatureB

\Server◦ FeatureA

◦ FeatureB

◦ Shared

\Datastore

Page 12: YOW West 2017 - YOW! Conference...YOW West 2017 OUR SPONSORS Cost of a dependency Trainer Dev at –CashiesPractical Rx Lee Campbell Author of eBook and website IntroToRx.com Conference

Single repo\GUI

◦ FeatureA

◦ FeatureB

◦ FeatureC

\Server◦ FeatureA

◦ FeatureB

◦ FeatureC

◦ Shared◦ Logic

◦ Scripts (Builds, Deployments)

\Datastore

Page 13: YOW West 2017 - YOW! Conference...YOW West 2017 OUR SPONSORS Cost of a dependency Trainer Dev at –CashiesPractical Rx Lee Campbell Author of eBook and website IntroToRx.com Conference

Single repo\GUI

◦ FeatureA

◦ FeatureB

◦ FeatureC

\Server◦ FeatureA

◦ FeatureB

◦ FeatureC

◦ Shared◦ Logic

◦ Scripts (Builds, Deployments)

\Datastore◦ FeatureA

◦ FeatureB

◦ FeatureC

Page 14: YOW West 2017 - YOW! Conference...YOW West 2017 OUR SPONSORS Cost of a dependency Trainer Dev at –CashiesPractical Rx Lee Campbell Author of eBook and website IntroToRx.com Conference

Single repo\GUI

◦ FeatureA

◦ FeatureB

◦ FeatureC

◦ Shared

\Server◦ FeatureA

◦ FeatureB

◦ FeatureC

◦ Shared◦ Logic

◦ Contracts

\Framework◦ Comms Layer

◦ Data Persistence abstraction

◦ Scripts (Builds, Deployments)

\Datastore◦ FeatureA

◦ FeatureB

◦ FeatureC

Page 15: YOW West 2017 - YOW! Conference...YOW West 2017 OUR SPONSORS Cost of a dependency Trainer Dev at –CashiesPractical Rx Lee Campbell Author of eBook and website IntroToRx.com Conference

Single repoWho defines requirements and budget for each part of the system?

Can this progression be maintained for the expected lifetime of the system?

Do these things change together?

Page 16: YOW West 2017 - YOW! Conference...YOW West 2017 OUR SPONSORS Cost of a dependency Trainer Dev at –CashiesPractical Rx Lee Campbell Author of eBook and website IntroToRx.com Conference

Single repo - ConsequencesBuild times increase

Testing burden

Friction to innovate

Blurry boundaries

Lack of responsibility

Page 17: YOW West 2017 - YOW! Conference...YOW West 2017 OUR SPONSORS Cost of a dependency Trainer Dev at –CashiesPractical Rx Lee Campbell Author of eBook and website IntroToRx.com Conference

2. Depend on abstractions

Page 18: YOW West 2017 - YOW! Conference...YOW West 2017 OUR SPONSORS Cost of a dependency Trainer Dev at –CashiesPractical Rx Lee Campbell Author of eBook and website IntroToRx.com Conference

Interface all the thingsView Models

Translators

Validators

Page 19: YOW West 2017 - YOW! Conference...YOW West 2017 OUR SPONSORS Cost of a dependency Trainer Dev at –CashiesPractical Rx Lee Campbell Author of eBook and website IntroToRx.com Conference
Page 20: YOW West 2017 - YOW! Conference...YOW West 2017 OUR SPONSORS Cost of a dependency Trainer Dev at –CashiesPractical Rx Lee Campbell Author of eBook and website IntroToRx.com Conference
Page 21: YOW West 2017 - YOW! Conference...YOW West 2017 OUR SPONSORS Cost of a dependency Trainer Dev at –CashiesPractical Rx Lee Campbell Author of eBook and website IntroToRx.com Conference

ConsequencesTesting now becomes an exercise in mocking

Debugging is always a case of hitting finding "implementations of"

Page 22: YOW West 2017 - YOW! Conference...YOW West 2017 OUR SPONSORS Cost of a dependency Trainer Dev at –CashiesPractical Rx Lee Campbell Author of eBook and website IntroToRx.com Conference
Page 23: YOW West 2017 - YOW! Conference...YOW West 2017 OUR SPONSORS Cost of a dependency Trainer Dev at –CashiesPractical Rx Lee Campbell Author of eBook and website IntroToRx.com Conference
Page 24: YOW West 2017 - YOW! Conference...YOW West 2017 OUR SPONSORS Cost of a dependency Trainer Dev at –CashiesPractical Rx Lee Campbell Author of eBook and website IntroToRx.com Conference
Page 25: YOW West 2017 - YOW! Conference...YOW West 2017 OUR SPONSORS Cost of a dependency Trainer Dev at –CashiesPractical Rx Lee Campbell Author of eBook and website IntroToRx.com Conference

ConsequencesFocus is diluted

Cognitive load is increased through indirection

Page 26: YOW West 2017 - YOW! Conference...YOW West 2017 OUR SPONSORS Cost of a dependency Trainer Dev at –CashiesPractical Rx Lee Campbell Author of eBook and website IntroToRx.com Conference

Depend on (external) abstractionsWe can also take dependencies on interface define by someone else

So maybe you just mock out your ◦ IoC Continer

◦ SqlConnection

◦ ORM UnitOfWork

But these are normally defined in their package, with the implementation.

Page 27: YOW West 2017 - YOW! Conference...YOW West 2017 OUR SPONSORS Cost of a dependency Trainer Dev at –CashiesPractical Rx Lee Campbell Author of eBook and website IntroToRx.com Conference

3. Deep layering

Page 28: YOW West 2017 - YOW! Conference...YOW West 2017 OUR SPONSORS Cost of a dependency Trainer Dev at –CashiesPractical Rx Lee Campbell Author of eBook and website IntroToRx.com Conference

Deep layeringDeep system dependencies

Page 29: YOW West 2017 - YOW! Conference...YOW West 2017 OUR SPONSORS Cost of a dependency Trainer Dev at –CashiesPractical Rx Lee Campbell Author of eBook and website IntroToRx.com Conference

Deep layering

Page 30: YOW West 2017 - YOW! Conference...YOW West 2017 OUR SPONSORS Cost of a dependency Trainer Dev at –CashiesPractical Rx Lee Campbell Author of eBook and website IntroToRx.com Conference

Deep layeringMy application

◦ My libraries◦ My Framework

◦ My Framework subsystem

◦ Generic public packages

◦ Low level generic public packages

Page 31: YOW West 2017 - YOW! Conference...YOW West 2017 OUR SPONSORS Cost of a dependency Trainer Dev at –CashiesPractical Rx Lee Campbell Author of eBook and website IntroToRx.com Conference

Deep layeringMy application

◦ My libraries (Domain, Data Access, Comms, Controls, Styles)◦ My Framework (DataAccess, Comms, Contracts, Generic Utilities, Controls, Styles)

◦ My Framework subsystem (Implementation specific DataAccess, Comms etc)

◦ Generic public packages (ORM, Serializers, Web Platform, Messaging, Document manipulation)

◦ Low level generic public packages (Network interfaces, Collections Libraries)

Page 32: YOW West 2017 - YOW! Conference...YOW West 2017 OUR SPONSORS Cost of a dependency Trainer Dev at –CashiesPractical Rx Lee Campbell Author of eBook and website IntroToRx.com Conference

Deep layeringNon linear growth

3 deep with each dependency having 3 children

1 + 3 + 9 = 13 total

Page 33: YOW West 2017 - YOW! Conference...YOW West 2017 OUR SPONSORS Cost of a dependency Trainer Dev at –CashiesPractical Rx Lee Campbell Author of eBook and website IntroToRx.com Conference

Deep layeringNon linear growth

Add 2 more layers (5 layers)

1 + 3 + (9 * 13) = 121 total

1

1 1 1

13 13 13 13 13 13 13 13 13

Page 34: YOW West 2017 - YOW! Conference...YOW West 2017 OUR SPONSORS Cost of a dependency Trainer Dev at –CashiesPractical Rx Lee Campbell Author of eBook and website IntroToRx.com Conference

Deep layeringNon linear growth

Add 2 more layers (7 layers)

1 + 3 + (9 * 121) = 1093 total

1

1 1 1

121 121 121 121 121 121 121 121 121

Page 35: YOW West 2017 - YOW! Conference...YOW West 2017 OUR SPONSORS Cost of a dependency Trainer Dev at –CashiesPractical Rx Lee Campbell Author of eBook and website IntroToRx.com Conference

+ baggagePackages that include

◦ minified and original resource

◦ Documentation (JavaDoc/Intellisense)

◦ Tooling

Page 36: YOW West 2017 - YOW! Conference...YOW West 2017 OUR SPONSORS Cost of a dependency Trainer Dev at –CashiesPractical Rx Lee Campbell Author of eBook and website IntroToRx.com Conference

Deep call stacksI depend on abstractions

But they also depend on abstractions

So I have deep call stacks

Page 37: YOW West 2017 - YOW! Conference...YOW West 2017 OUR SPONSORS Cost of a dependency Trainer Dev at –CashiesPractical Rx Lee Campbell Author of eBook and website IntroToRx.com Conference

Deep call stackshttps://twitter.com/gregyoung/status/734713437146734592

Page 38: YOW West 2017 - YOW! Conference...YOW West 2017 OUR SPONSORS Cost of a dependency Trainer Dev at –CashiesPractical Rx Lee Campbell Author of eBook and website IntroToRx.com Conference
Page 39: YOW West 2017 - YOW! Conference...YOW West 2017 OUR SPONSORS Cost of a dependency Trainer Dev at –CashiesPractical Rx Lee Campbell Author of eBook and website IntroToRx.com Conference

ConsequencesCognitive load increases exponentially with each layer

Technical freedom is slowly eroded as each layer add more dependencies

Page 40: YOW West 2017 - YOW! Conference...YOW West 2017 OUR SPONSORS Cost of a dependency Trainer Dev at –CashiesPractical Rx Lee Campbell Author of eBook and website IntroToRx.com Conference

Compounding Consequences

Page 41: YOW West 2017 - YOW! Conference...YOW West 2017 OUR SPONSORS Cost of a dependency Trainer Dev at –CashiesPractical Rx Lee Campbell Author of eBook and website IntroToRx.com Conference

Compounding consequencesBuild times

Test times

Lack of Ownership

Page 42: YOW West 2017 - YOW! Conference...YOW West 2017 OUR SPONSORS Cost of a dependency Trainer Dev at –CashiesPractical Rx Lee Campbell Author of eBook and website IntroToRx.com Conference

Compensating behaviourMagic Build scripts

Using the real IoC Container in tests

AOP

Page 43: YOW West 2017 - YOW! Conference...YOW West 2017 OUR SPONSORS Cost of a dependency Trainer Dev at –CashiesPractical Rx Lee Campbell Author of eBook and website IntroToRx.com Conference

Complicated becomes complexCant be rationalised about

Emergent behaviour (bugs, not features)

Page 44: YOW West 2017 - YOW! Conference...YOW West 2017 OUR SPONSORS Cost of a dependency Trainer Dev at –CashiesPractical Rx Lee Campbell Author of eBook and website IntroToRx.com Conference

AlternativesIS THERE A BETTER WAY?

Page 45: YOW West 2017 - YOW! Conference...YOW West 2017 OUR SPONSORS Cost of a dependency Trainer Dev at –CashiesPractical Rx Lee Campbell Author of eBook and website IntroToRx.com Conference

Single repoFEATURE DEPENDENCY

Page 46: YOW West 2017 - YOW! Conference...YOW West 2017 OUR SPONSORS Cost of a dependency Trainer Dev at –CashiesPractical Rx Lee Campbell Author of eBook and website IntroToRx.com Conference

If it changes together, it lives togetherWays to identify

◦ The person that has final say on requirements is different

◦ Release cadences are different

◦ Code change cadence is different

◦ Failures are ignored

"Decompose your applications based on volatility" - Juval Lowy

Page 47: YOW West 2017 - YOW! Conference...YOW West 2017 OUR SPONSORS Cost of a dependency Trainer Dev at –CashiesPractical Rx Lee Campbell Author of eBook and website IntroToRx.com Conference

Single repo\GUI

◦ FeatureA

◦ FeatureB

◦ FeatureC

◦ Shared

\Server◦ FeatureA

◦ FeatureB

◦ FeatureC

◦ Shared◦ Logic

◦ Contracts

\Framework◦ Comms Layer

◦ Data Persistence abstraction

◦ Scripts (Builds, Deployments)

\Datastore◦ FeatureA

◦ FeatureB

◦ FeatureC

Page 48: YOW West 2017 - YOW! Conference...YOW West 2017 OUR SPONSORS Cost of a dependency Trainer Dev at –CashiesPractical Rx Lee Campbell Author of eBook and website IntroToRx.com Conference

Multi repoFeatureA

◦ GUI

◦ Server

◦ DataStore

◦ Contracts

FeatureB◦ GUI

◦ Server

◦ DataStore

◦ Contracts

FeatureC

◦ GUI

◦ Server

◦ DataStore

◦ Contracts

GUI Lib

Comms Lib

Persistence Lib

Page 49: YOW West 2017 - YOW! Conference...YOW West 2017 OUR SPONSORS Cost of a dependency Trainer Dev at –CashiesPractical Rx Lee Campbell Author of eBook and website IntroToRx.com Conference

Multi repoInherently parallel to build and test

Forces the discussion about design by contract

Can reduce the knee jerk reaction to share code

Page 50: YOW West 2017 - YOW! Conference...YOW West 2017 OUR SPONSORS Cost of a dependency Trainer Dev at –CashiesPractical Rx Lee Campbell Author of eBook and website IntroToRx.com Conference

Encapsulation

Page 51: YOW West 2017 - YOW! Conference...YOW West 2017 OUR SPONSORS Cost of a dependency Trainer Dev at –CashiesPractical Rx Lee Campbell Author of eBook and website IntroToRx.com Conference

Justify the interfaceWhat is the benefit of this being injected?

Can it be encapsulated into this unit?

Page 52: YOW West 2017 - YOW! Conference...YOW West 2017 OUR SPONSORS Cost of a dependency Trainer Dev at –CashiesPractical Rx Lee Campbell Author of eBook and website IntroToRx.com Conference
Page 53: YOW West 2017 - YOW! Conference...YOW West 2017 OUR SPONSORS Cost of a dependency Trainer Dev at –CashiesPractical Rx Lee Campbell Author of eBook and website IntroToRx.com Conference

Private by defaultInstead of Reuse being a goal, aim for encapsulation.

Rule of 3

Reuse is an evolution

Page 54: YOW West 2017 - YOW! Conference...YOW West 2017 OUR SPONSORS Cost of a dependency Trainer Dev at –CashiesPractical Rx Lee Campbell Author of eBook and website IntroToRx.com Conference

The snip ruleAvoid dependencies that require finesse to remove

Single line to cut

Page 55: YOW West 2017 - YOW! Conference...YOW West 2017 OUR SPONSORS Cost of a dependency Trainer Dev at –CashiesPractical Rx Lee Campbell Author of eBook and website IntroToRx.com Conference

Code in actionA DOMAIN MODEL WITH NO DEPENDENCIES

Page 56: YOW West 2017 - YOW! Conference...YOW West 2017 OUR SPONSORS Cost of a dependency Trainer Dev at –CashiesPractical Rx Lee Campbell Author of eBook and website IntroToRx.com Conference

Only depends on .NET

Page 57: YOW West 2017 - YOW! Conference...YOW West 2017 OUR SPONSORS Cost of a dependency Trainer Dev at –CashiesPractical Rx Lee Campbell Author of eBook and website IntroToRx.com Conference

So how does it do anythingThe Domain Model defines the interfaces for the things it needs

◦ IRepository<T>

Can you tell what technology we are using here?

Consumers are responsible to implement it

We are isolating the business logic from our technology choices.

Page 58: YOW West 2017 - YOW! Conference...YOW West 2017 OUR SPONSORS Cost of a dependency Trainer Dev at –CashiesPractical Rx Lee Campbell Author of eBook and website IntroToRx.com Conference

Inversion of Control

Page 59: YOW West 2017 - YOW! Conference...YOW West 2017 OUR SPONSORS Cost of a dependency Trainer Dev at –CashiesPractical Rx Lee Campbell Author of eBook and website IntroToRx.com Conference

Hosts compose shallow dependenciesHexagonal Architecture (Alistair Cockburn)

Ports and Adapters

Onion Architecture

Page 60: YOW West 2017 - YOW! Conference...YOW West 2017 OUR SPONSORS Cost of a dependency Trainer Dev at –CashiesPractical Rx Lee Campbell Author of eBook and website IntroToRx.com Conference

We define our PortsIRepository is one of our ports

We may have a SQLServer adapter, or perhaps a MongoDB one

Page 61: YOW West 2017 - YOW! Conference...YOW West 2017 OUR SPONSORS Cost of a dependency Trainer Dev at –CashiesPractical Rx Lee Campbell Author of eBook and website IntroToRx.com Conference

Composition

App Service

Domain Model

Data Service

ORM Data store

Comms Service

SerializationMessaging platform

Page 62: YOW West 2017 - YOW! Conference...YOW West 2017 OUR SPONSORS Cost of a dependency Trainer Dev at –CashiesPractical Rx Lee Campbell Author of eBook and website IntroToRx.com Conference

Composition

Domain Model

Commsadapter

Data adapter

App Service

Data store

Comms

Page 63: YOW West 2017 - YOW! Conference...YOW West 2017 OUR SPONSORS Cost of a dependency Trainer Dev at –CashiesPractical Rx Lee Campbell Author of eBook and website IntroToRx.com Conference

AdaptersCODE BREAK OUT

Page 64: YOW West 2017 - YOW! Conference...YOW West 2017 OUR SPONSORS Cost of a dependency Trainer Dev at –CashiesPractical Rx Lee Campbell Author of eBook and website IntroToRx.com Conference

Composition instead of AOPI can just use normal old Decorator pattern

Page 65: YOW West 2017 - YOW! Conference...YOW West 2017 OUR SPONSORS Cost of a dependency Trainer Dev at –CashiesPractical Rx Lee Campbell Author of eBook and website IntroToRx.com Conference

ResultsMulti repo

◦ Division of labour

◦ Cohesive code base

◦ Reduced cognitive load

◦ Technical freedom

Page 66: YOW West 2017 - YOW! Conference...YOW West 2017 OUR SPONSORS Cost of a dependency Trainer Dev at –CashiesPractical Rx Lee Campbell Author of eBook and website IntroToRx.com Conference

ResultsEncapsulation

◦ Reduced cognitive load

◦ Less busy work

◦ Snip rule

Page 67: YOW West 2017 - YOW! Conference...YOW West 2017 OUR SPONSORS Cost of a dependency Trainer Dev at –CashiesPractical Rx Lee Campbell Author of eBook and website IntroToRx.com Conference

ResultsInversion of Dependencies / Ports and Adapter

◦ Focused code

◦ Fast tests

◦ Shallow stacks

◦ Technical Freedom

Page 68: YOW West 2017 - YOW! Conference...YOW West 2017 OUR SPONSORS Cost of a dependency Trainer Dev at –CashiesPractical Rx Lee Campbell Author of eBook and website IntroToRx.com Conference

Know your costsCognitive load

Onboarding friction

Technical Freedom

Time to prod

Page 69: YOW West 2017 - YOW! Conference...YOW West 2017 OUR SPONSORS Cost of a dependency Trainer Dev at –CashiesPractical Rx Lee Campbell Author of eBook and website IntroToRx.com Conference

More informationLeeCampbell.com

Implementing Domain Driven Design – Vaugh Vernon

Greg Young – Good enough software

Hex Arch – Alistair Cockburn

Having the computer to do what you want isn’t the hard part,having a person understand the intent of your code is.