Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Build Libraries That People Love To use

383 views

Published on

Frameworks are supposed to help you build things more quicker and hide a lot of complexity around cross-cutting and infrastructural concerns. They are supposed to make it easier for inexperienced developers to join a running projection. But frameworks also introduce a lot of magic, and that magic is going to backfire at some point. At least, that's my experience. And when it backfires, your code is so entangled with that framework, that you can't get rid of it anymore.

So, instead of building and using frameworks, build and use libraries. That's easier said then done, and I'll can talk about many great and not so great examples. So let me share some of the practices I use to build composable libraries myself. I'll talk about principles of package design and scoping, keeping your NuGet package dependencies in check, and how to use layered APIs to increase usability without hiding the magic.

Published in: Software
  • Be the first to comment

  • Be the first to like this

Build Libraries That People Love To use

  1. 1. Dennis Doomen | @ddoomen | Aviva Solutions | The Continuous Improver
  2. 2. …and badly designed libraries
  3. 3. Library Consumer Bunch of classes that can be used directly X No inheritance Uses composition over inheritance internally Convenience classes that don’t hide the magic Main Package Shared Package Contract Contract Only depend on more abstract packages… Stable Package …or depend on more stable packages Auxiliary Package Classes that are not used together do not belong togetherOptional Dependency Dependency Package Consumers should not be faced with optional dependencies
  4. 4. 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);
  5. 5. e.g. LibLog, TinyIoc, FluidCaching
  6. 6. Command Handlers Commands Domain Model Event Store Events App Persistent Projections RavenDB/Nhibernate/Raw SQL Projectors Events API Controller Projections Events
  7. 7. Library Consumer LiquidProjections LiquidProjections.Abstractions Transaction Delegates LiquidProjections. NEventStore NHibernate LiquidProjections NHibernate RavenDB LiquidProjections RavenDB LiquidProjections. Testing
  8. 8. • Liquid Projections – The Example https://github.com/liquidprojections • Principal for Successful Package Management http://www.continuousimprover.com/2016/10/princi ples-for-successful-package.html • The magic of hiding your NuGet dependencies http://www.continuousimprover.com/2016/05/the- magic-of-hiding-your-nuget.html • To DRY or not to DRY, it is a matter of boundaries http://www.continuousimprover.com/2016/05/the- magic-of-hiding-your-nuget.html • 12 tips to write unit tests that don’t cripple your code base http://www.continuousimprover.com/2015/11/12- tips-to-write-unit-tests-that-dont.html

×