Evolving Identifiers and Total Maps

8th December 2014 in London at Business Design Centre

There are 54 other SkillsCasts available from Scala eXchange 2014

Please log in to watch this conference skillscast.

500413220 640

You've used standard type-safe practices and immutable structures to build applications that are quite reliable. You still deal with failure modes that are not caught by the compiler. Could you reasonably go further and gain extra safety? We'll look at a key invariant that goes unchecked in most applications and then show how approachable it can be in Scala with support from a small library named total-map (github.com/boldradius/total-map).

Map data structures are often used quite liberally to associate data to entities, such as users, sessions or transactions. Those are typically identified by a numeric key. This works well for optional data, but often we'd like to guarantee that data is present for every entity.

We show how identifier types can evolve to track dynamic sets of entities. We use these types as keys to build total maps. Since lookups in total maps are always successful, we can eliminate important error-handling code paths and increase application reliability. We walk through the conversion of an application from maps to total maps and discuss benefits, challenges and alternatives.


Thanks to our sponsors

Evolving Identifiers and Total Maps

Patrick Premont

Patrick is a Functional Programming Architect at BoldRadius Solutions where he helps clients build reliable applications in Scala.