Build Libraries, Not Frameworks

Post on 21-Jan-2018

394 views 0 download

Transcript of Build Libraries, Not Frameworks

BUILD LIBRARIES, NOT FRAMEWORKSOr how to build packages that people want to use

Dennis Doomen | @ddoomen

…and badly designed libraries

Library Consumer

Bunch of classes that should be used directly

X

No inheritance

Uses composition over inheritance

internally

Convenience classes that don’t hide the

magic

Main Package

Contract Package

Contract

Contract

Only depend on abstract packages…

Stable Package

…or depend on more stable packages

Auxiliary Package

Classes that are not used together do not

belong togetherOptional Dependency

DependencyPackage

Consumers should not be faced with

optional dependencies

public interface IEventStore{

IDisposable Subscribe(long? lastCheckpoint, Func<Transaction[]>, Task> handler,string subscriptionId);

}

public delegate IDisposable CreateSubscription(long? lastCheckpoint,Func<Transaction[]>, Task> handler,string subscriptionId);

Command Handlers

Commands

Domain Model

Event Store

Events

App

PersistentProjections

RavenDB/Nhibernate/Raw SQL

ProjectorsEvents

API Controller

Projections

Events

Library Consumer

LiquidProjections

LiquidProjections.Abstractions

Transaction

Delegates

LiquidProjections. NEventStore

NHibernate

LiquidProjectionsNHibernate

RavenDB

LiquidProjectionsRavenDB

LiquidProjections. Testing

• Liquid Projections – The Examplehttps://github.com/liquidprojections

• Principal for Successful Package Managementhttp://www.continuousimprover.com/2016/10/principles-for-successful-package.html

• The magic of hiding your NuGet dependencieshttp://www.continuousimprover.com/2016/05/the-magic-of-hiding-your-nuget.html

• To DRY or not to DRY, it is a matter of boundarieshttp://www.continuousimprover.com/2016/05/the-magic-of-hiding-your-nuget.html

• 12 tips to write unit tests that don’t cripple your code basehttp://www.continuousimprover.com/2015/11/12-tips-to-write-unit-tests-that-dont.html