How to learn Domain-Driven Design & Event Sourcing? My own Developer Journey Map and useful resources.
Tags: ddd, eventsourcing, domaindrivendesign, learning
Published: 2021-04-21 14:54:28

Have you ever heard about Domain-Driven Design or Event Sourcing and you want to get familiar with those exciting techniques? 

## TL; DR
You can find the map of my developer journey (with DDD & Event Sourcing resources) below:
[MIRO BOARD LINK - Developer Journey Map - DDD & Event Sourcing](https://miro.com/app/board/o9J_lOPIH-Y=/?moveToWidget=3074457357614202364&cot=14)


## Every single time
But the problem is the same as always. When your journey with programming just began you were probably asking: *Where to learn? What should I learn? What should I do at first? How long may it takes to be hired? What are best practices?*

The story repeats with new things to learn. *Where to find resources? In which order should I watch them (like Star Wars movies)?*
Prepare own learning path is not so easy. So, I've done it for you, young Padawan!

## 3 years of exploration in one place
I've been learning those concepts for about 3 years. Almost every day I read new posts / books etc. related to those topics. I've fallen in love with DDD and ES just when I've heard about them from the best lecturer on my university.
I believe those techniques may prevent a lot of bad decisions and save your software projects. DDD is not only about coding patterns, the most important part (strategic patterns) are about searching solution for business problems (solution may be a piece of software, but is not required). 

## What? Your CODE is evolving!

![CodeEvolution](https://cdn2.bulbagarden.net/upload/5/56/Evolution_FRLGE.png)
  

But the readable code is a side effect of good design decision in the spirit of DDD. Below you can see how my coding style of domain model evolves with those techniques in mind.

#### BEFORE
```kotlin
fun changeMaximumRetention(maxRetention: Int): DataRetention {
  if(isValidRetention(maxRetention)){
    throw new InvalidRetentionException(maxRetention);
  }
  if(this.deletionIsPaused){
    return DataRetention(this.id, maxRetentionDays, this.days, this.deletionIsPaused, this.pauseReason)
  }
  return DataRetention(this.id, maxRetentionDays, this.days, true, "Paused due to maximum data retention update")
}
```
Do not stop so long on this piece of code... Let's move to the next one.

#### AFTER
```kotlin
fun changeMaximumRetention(maxRetention: RetentionDays)
: List<DomainEvent> {
  val maximumRetentionWasChanged = MaximumRetentionWasChanged
       .event(maxRetentionDays);
  val deletionWasPaused = DeletionWasPaused
       .event("Paused due to maximum data retention update");

  return if(this.deletionIsPaused)
    listOf(maximumRetentionWasChanged)
  else
    listOf(maximumRetentionWasChanged, deletionWasPaused)
}
```
Reasoning about this code is so simple right now, even if you don't know the domain. I hope that you see what are the business rules here:
- *Given data deletion is paused, when change maximum retention, then maximum retention should be changed to new value.*
- *Given data deletion is not paused, when change maximum retention, then maximum retention should be changed to new value and data deletion should be paused.*

## Developer Journey Map
I've prepared Miro Board with a mind map which will guide you. You can find where to start your own developer journey today! There is a lot of Domain-Driven Design & Event Sourcing resources to discover. There are also sample projects which I recommend to watch. I hope, that following my footsteps will make you a better developer day by day.

Let's grab the map below!
[MIRO BOARD LINK - Developer Journey Map - DDD & Event Sourcing](https://miro.com/app/board/o9J_lOPIH-Y=/?moveToWidget=3074457357614202364&cot=14)


![emma-van-sant-n8V1Zht4U54-unsplash](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7lptanjqa2i763mvub9f.jpg) 
 
 I'm sure that those resources will give you a strong theoretical background and will be a compass on your way to practice and mastery. 
Let's begin your own journey and catch'em all!


## This is the way

Are you already on the way?
Maybe do you recommend some other resources which I should place on the map? Or have you already learn something from them? Please let me know in the comments :) 
I will be updating the map which new discoveries, so be sure to return here from time to time.

-----

📧 I encourage you to join my [mailing list](subscribepage.io/mateusznowak). Here you will find more content like this and also have opportunity to learn with me :)