Lean and Functional Domain Modelling

Two day workshop
Marcello Duarte

Lean and Functional Domain Modelling

No dates are scheduled for this workshop. Let us know if you think we should organize it near you, or if you'd like to book it on premise in your organisation.

Rich domain models, inspired by imperative objective-oriented approaches, dominate our industry.
Lean and functional domain models are a compelling alternative. By separating behaviour and state, lean models offer an effective and scalable way to represent units of behaviour. With the advances in cloud-based infrastructures and implementation of microservices architectures, functional models seems to be a compatible, resilience enabling and more obvious choice as the preferred paradigm.

In this workshop we will explore

  • How to reason about selected aspects of a problem domain using a lean domain model from a functional programming paradigm
  • How types can be used as a natural way to represent business constraints alongside smart constructors and functional validation
  • How behaviour can be better composed, and how to keep domain behaviour isolated from application state.

What will you learn in this course

  • Modelling techniques to express selected behaviours in a problem domain, using real world use cases
  • Revision of essential Scala features
  • Model data using algebraic data types, represented in Scala as families of sealed traits and case classes
  • Using functional thinking to approach problem solving
  • Understanding functional patterns for creation, validation, behaviour execution, persistency and state management
  • How to express computation as types and create your own domain algebra
  • Using Property based testing for modelling business constraints
  • Exploring common challenges in real world domain modelling with somebody who has worked with many teams in the field.


Day 1

  • Brief intro to Scala, Scala Repl
  • Functional programming building blocks, basic definitions, pure functions
  • Referential transparency
  • Functions, function literals, function as objects, high order functions
  • Kinds, proper, first order kinds, higher order kinds, genericity
  • Functional patterns, composition, combinators, functors, monands
  • Applicatives, options, either, try, list.

Day 2

  • Lean Domain Modelling. Explicit and Verifiable Domain model algebra. Boundary Contexts
  • Invariants. Creating valid values and objects. Using disjunctions for validation
  • Alternative to Layered Architecture. Separating Boundaries with Monads.State Monad. IO Monad. Monad Transformers. Kleisli Arrows
  • Decoupling from the DB
  • Property Based Testing. Defining domain constraints with Types. Composing the domain algebra.

Expect to get your hands dirty

This is a very hands-on course. All modules are packed with exercises. You will benefit mostly by being alert, attentive and engaged while we work on the exercises (although you will get all solutions at the end).

Who should attend this course?

Developer seeking an alternative way to approach Domain modelling.
Experienced developers with a strong background in software development should be able to follow this workshop and benefit from it.

No experience with Scala is assumed, but strong experience with Java, C# or PHP would be highly beneficial.


You will need to have a laptop with an IDE (like intelliJ, Sublime or Eclipse) or an editor (like Vim or Emacs).

Marcello Duarte

About Marcello Duarte

Marcello is a Sociologist turned techie, he also holds a Licentiate degree on Computing for Management. Because of his rich/mixed background (did I mention he was a Hindu monk for 6 years?) he is usually the person between the IT people and the business people.

He has been awarded “Best UK Agile Coach/Mentor (Technical)” at the UK Agile Awards, in 2014. He’s been involved in the Agile community for over 10 years now. Marcello participated in the first ever Scrum certification to take place in Portugal. He’s conducted agile transformations and trained over 500 individuals in many organisations in Europe on a range of topics like Software Design and Modelling, Test Driven Development, Agile Coaching for Coaches, Refactoring, Training the trainer, etc.

In his current position as Head of L&D at YLD, Marcello leads the company learning practices, agile transformation, adoption and absorption of new technologies and practices and the external training offer.

Marcello often contributes to Open Source projects. He’s co-created PhpSpec, a popular BDD-flavoured testing and design tool for PHP developers. He is also the author of Phunkie — a functional library containing most common functional structures and patterns found in Haskell (for free), based on the abstract algebra theory of categories.

All workshops by Marcello Duarte

No dates are scheduled for this workshop. Let us know if you think we should organize it near you, or if you'd like to book it on premise in your organisation.

Also check out