This is the foreword I wrote for Debasish Ghosh’s great book on Functional and Reactive Domain Modeling.
Available from Manning here.
Foreword
We—developers—are drowning in complexity: we need to support a rapidly growing number of highly demanding users, producing more and more data, with lower latency and higher throughput; having to take advantage of multicore processors and distributed infrastructures; and shipping in time under tight deadlines for our ever demanding customers.
Our jobs were never that easy, and in order to stay productive and enjoying our work, what I think we need is the right set of tools to manage the growing complexity and requirements. As always, the answer is never as simple as to chase the newest, shiniest, things—even though it is tempting—but rather to look back, and learn from the hard-won wisdom of the past and see if there is a way to apply it to the contexts and challenges of today. What I consider amongst the most useful tools of the past are: Domain-Driven Design (DDD), Functional Programming (FP), and Reactive principles—each one helping us manage an axis of complexity:
- Domain complexity: Domain-Driven Design helps us mine and understand the distinct characteristics and semantics of the domain. By communicating with the stakeholders in their own language, it makes it easier to create extensible domain models that maps to the real world while allowing for continuous change.
- Solution complexity: Functional Programming helps us with reasonability and composability. Through the use of reusable pure functions, working on stable (immutable) values, it gives us great toolset to reason about time, concurrency and abstraction through (referentially transparent) code that does not “lie”.
- System complexity: The Reactive principles—as defined in the Reactive Manifesto—can help us manage the increasingly complex world of multi-core processors, cloud computing, mobile devices and the Internet of Things. In which essentially all new systems are distributed systems from day one—a vastly different, and more challenging world to operate in, but also a world with lots of new and interesting opportunities. A shift that has forced our industry to rethink some of its old “best practices” around system architecture and design.
I absolutely enjoyed reading this book, and it very much represents my own journey over the last 10 years: I started out as an OO practitioner—hacking C++ and Java during the day and reading the classic “Gang of Four” book during the night. Then in 2006 I discovered Eric Evans’ book on Domain-Driven Design—and it was more or less a revelation which turned me into some kind of DDD aficionado, applying it everywhere I could. A couple of years later I started tinkering with Erlang, and later Scala, which made me rediscover, and fall in love with, Functional Programming—something that I had studied at the university back in the day, but not understood the true power of—until now. Around this time I had also started to lose faith in Enterprise Java’s “best practices” around concurrency, resilience, and scalability. Frustrated and guided by a better way of doing things—the Erlang way, and specifically the Actor Model—I started the Akka project, which I believe has helped taking the Reactive principles into the mainstream.
What captured me about this book is that it sets out on the, rather bold, mission of bringing these three very different tools and principles together—in a practical way. It teaches you how things like Bounded Contexts, Domain Events, Functions, Monads, Applicatives, Futures, Actors, Streaming and CQRS can help you keep complexity under control—and it pulls it off. This is not a book for the faint of heart. It is demanding. But if you put in the hours you will be rewarded in spades. Fortunately for you, dear reader, is that you’ve already taken the first step, all you have to do is keep on reading.
—Jonas Bonér, Founder and CTO of Lightbend, Creator of Akka