Richard Searle

home

Reconsidering the cake pattern

27 Oct 2014

This set of best practices contains some interesting ideas.

The recommendation to avoid the Cake Pattern, combined with a DI suggestion are particularly interesting.

The Cake Pattern is essentially an OO pattern that uses Inheritance for Implementation, which is generally considered an anti-pattern. OO design standards have evolved with experience, recommending composition over inheritance.

The conventional Java interface based DI

trait DBService {
  def getAssets: Future[Seq[(AssetConfig, AssetPersistedState)]]
}

is replaced by a flat, functional design

f: => Future[Seq[(AssetConfig, AssetPersistedState)]]