Lagom resources

Videos

Introduction to Lagom

This is a video introduction and quick explanation of Lagom


Lagom Developer Setup

This short video describes how to setup a Lagom project

Events-First Microservices with Lagom by Gideon de Kok

Tom Peck – Building Better Microservices with Lagom

What can Lagom Do for you?

CQRS and Event Sourcing with Lagom by Miel Donkers


From CRUD to Event Sourcing Why CRUD is the wrong approach for microservices

This video doesn’t mention it but it is about Lagom and how it is used to create microservices. This is a video  I will watch more than once and write notes about.  This video is complete with some code examples found here on github. This is a very helpful video if you are wondering how the hell Lagom works overall.

Articles

Your first microservices using Scala and Lagom. This is an interesting short article about Lagom. It is more or less a quick explanation of Lagom and how it works.

Deploying a Lagom Application to Openshift.  A lightbend article about how to deploy an application to to openshift.

Lagom Migration guide. This guide covers the changes from Lagom 1.4 to 1.5 the improvements etc. See the Docker images and deployment specs about kustomize

Here is a useful article about CQRS and Event Sourcing and how it relates to Lagom. CQRS and Event Sourcing with Lagom

Persistent read side in Lagom explained

Data persistence in Lagom  An article about saving your data in a Lagom Framework system.

Here is a really good article about lagom. If you are wondering why use lagom, especially since it uses AKKA and Play and you can just do that yourself, then this is the article for you.

Microservice resources

Microservice Resources

Most of us older people have been building monoliths for most of our careers. Now BAM! a new buzzyword is born Microservices. Microservices are all about tearing apart the dreaded monolith into smaller services that all function together to perform the actions of the monolith. Microservices have many benefits over Monoliths, however they have many disadvantages as well. Microservice systems are inherently distributed. Technology has changed so much recently. In the past we had to rent entire servers or virtual private servers etc.

Now we have the cloud, we can buy server power for super cheap, my favorite host Vultr.com has hosting packages for less than $5 USD. Vultr has the most awesome hosting interface for us Developers too. No intrusive demands for a credit card, you can pay with Paypal, Bitcoin and more.

This cheap hosting combined with containerization technology such as Docker/Kubernetes, and Frameworks such as Lagom means Microservices are getting much easier. So easy in fact your Startup can start with a Microservice Architecture based on Lagom.

I’ve spent about two years reading and researching Microservices below I list some of the Articles, Books and Videos that helped me along the way. I list these because there is a ton of old and bad information floating around the internettens and it took some effort to get to the bottom of what is currently the best accepted practices. This also gives me the ability to look back for information I can’t quite remember where I saw it since all I do is read, day and night.

Articles

Microservices guide by Martin Fowler this is an excellent first start.

This link has links to many useful articles about microservices, this is a great place to start.


Microservices communications. Why you should switch to message queues.
This article covers how message queues work in a microservices setting. How to integrate microservices with message queues and why it is better than HTTP endpoints with microservices discovery and load balancing tools.


Implementing event-based communication between microservices (integration events) This article covers using message queues for event-based microservice communication.


Service Mesh VS API Gateway VS Message Queue – when to use what?
This is a small article that covers some of the pros and cons of each communication architecture style.


Microservice pattern explained. This article covers the idea of the microservice pattern. It  covers the uses of the microservice pattern and compares it to the traditional Microservice pattern. This article glosses over communication between services. This article also covers the pros and cons of the microservice pattern. This article has good information about how to split your application into microservices, it has quite a few good links too.


 REST vs Messaging for Microservices – Which One is Best? This article has some information about microservice communication and how it has changed over time.


Message Broker or Bus – what’s the difference? This is a good article that explains the minute differences between a Message Bus and a Message Broker. One of the worst things about the Software Industry is all the gimmicky terms and buzzwords, it is enough to make you want to move on to Physics where bosons, quarks and leptons are the buzzwords.


The Saga Pattern This article describes a useful microservice communication pattern called the Saga pattern. This pattern has it’s uses but I would not use it everywhere. This pattern allows a series of events to be reversed if a condition is not met or something along the line of communication fails.


Principles for Microservices Integration

This article has some good information about transactions between microservices. This article also covers choreography vs orchestration. Orchestration leads to a highly coordinated system which can create more tight coupling between microservices because some central authority orchestrates everything it must know about everything. A choreographed system decreases coupling by using an event sourced approach allowing microservices to publish events and decide what to do when an even they are listening to occurs. See the section about Choreographed vs Orchestrated in the article.


How Integration Patterns Impact Your Microservices Architecture  This is a good article that quickly covers the most basic ways of integrating Microservices. This article also has some excellent Resource links at the bottom of the page.


Apache Kafka vs Enterprise services bus

While researching Kafka as a message broker I wanted to know what the difference between Kafka and an ESB was, this excellent article covers just that topic. It covers event sourced/based systems and how Kafka is used in this type of setup.


Positioning APIs and Services – Let’s End the Confusion

This article talks about SOA Software Oriented Architecture which was the prelude to Microservices. This article is from 2015, this is about the time the word Microservice was born. This shift from SOA to microservices has made researching microservices a pain in the ass since during the shift many things were copied over or renamed etc. It has been hard to find any sort of consensus on many of the patterns and software used to build microservices.

The article mentions how SOA uses Enterprise Service Buses (ESB) as a way to integrate services. It mentions that before ESB the services connected to each other directly. This article is actually an interesting read for those of us who have not been in the industry for 20  years, it is a great recent history lesson. Before SOA it was the monolithic architecture, the mega pains of which is what spawned the SOA culture. Once you are bitten by a monolithic pile of crap you never ever want to see or create one ever again, it is the worst horror filled nightmare one can endure.

 


Service Mesh vs API Gateway

This article explains the difference between a Service Mesh and API Gateway. It explains how a service mesh is similar to an API Gateway and how they are different. Consul is one example of an excellent Service Mesh software. Basically your services need a way to find each other and communicate and a service mesh is that how. Service mesh is not the only way for microservices to communicate, you can use Event/Message Brokers, however you still need the service mesh in order for the services to find the Message Broker to send it messages or subscribe etc. You will also need a service mesh to find your Database and other software instances. So a service mesh works with microservices to help them communicate with the resources they need.


What’s a service mesh? And why do I need one?

This is an excellent article that explains exactly what a service mesh is and why you need them in Microservice systems. This article covers the history of Service Mesh’s and predicts the future of them as well. This article covers mostly Linkerd and how wonderful it is as a service mesh.


Service Mesh for Microservices

This article does an excellent job of explaining what a service mesh is and how it works in a microservice environment. The diagrams in this article make it easier to understand what a service mesh is and it’s role in microservice communication. This article also covers the pros and cons of a service mesh.


Videos

Implementing Microservices with Scala and Akka


GOTO 2014 • Microservices • Martin Fowler

Martin begins this talk by asking “What is a microservice” and compares it to a monolith giving a nice definition of Microservices.  This video gives a good overview of microservices. Here is Martin Fowlers website link to microservices, lots of good links here, the same as the top link of the page. This video contains a lot of good information, Martin talks about the past and how we ended up with Microservice architecture. In this video he explains the move away from Enterprise Service Bus in the idea of dumb pipelines and smart end points. This is a very good very short explanation of Microservices and the rules of Microservices. Martin also talks about how we should design our microservices to fail and use monitoring for self healing. He also covers Microservices vs Service Oriented Architecture (SOA). At about the 18:00 mark Martin Talks about Microservices vs Monoliths and when you should choose which architecture, this topic is covered fairly thoroughly. Personally I would say Always avoid the monolith Always unless you like pain and misery. Also this video is from 2014, things have changed especially with Container Technology like Kubernetes and Docker, which make microservices much easier now.


Greg Young – The Long Sad History of MicroServices

The talk starts at about the 9:00 minute mark. Greg makes a great point about microservices – everyone has their own definition it seems. This video makes the point that the software industry repeats everything over and over, and likes to rebuild the wheel. This video mentions smart endpoints and dumb pipes as well if you are wondering what that is.

This video talks about Software Oriented Architecture (SOA) and how we ended up with Microservices which are basically SOA done correctly, or applying best concepts to SOA. Turns out SOA was a buzzword too, just like Microservices. Microservices is basically just a new buzzwordy term for SOA.

The concepts of Microservices are very old, if you are an older developer trying to wrap your head around these microservice concepts then this video will help clarify a lot of things for you. Greg talks about many of the misunderstood concepts of Microservices like how many lines of code and microservice cohesion. This video also covers the Database per service idea vs a single database per company.
|Greg also talks about how Microservices should be asynchronous and event driven and why. At 46:00 greg talks about securing events, very interesting concept. He makes the point that microservices are not a cure for everything and it is sort of a fad.


GOTO 2016 • The Entity Microservice Trap You May Be Doing It Wrong • Fred George

I like this video because Fred takes the time to explain the history of software design and development and slowly leads up to Microservices. This video will help you avoid some pitfalls of Microservice design and help clarify what Microservices really are and how they work.


GOTO 2017 • DDD Today – Modeling Uncertainty • Vaughn Vernon

In this video Vaughn talks about some of the misconceptions we have when we first start learning about Microservices. Through a series of funny stories he covers how most people think of microservices and DDD and how we should think of the two. Microservices are distributed systems and they require modeling uncertainty. This video will also help clarify what is going on with microservices, how do they communicate with commands and events etc. I like the coverage of how the commands, events and microservices should work in this video.  This video covers a lot and will help clarify some concepts of DDD and how they are used in Microservices.


Eric Evans DDD and Microservices: At Last, Some Boundaries!

This video covers Domain Driven Design and boundaries between microservices.  Eric also covers some of the decisions that need to be made on how microservices communicate with each other.


Developing microservices with aggregates – Chris Richardson

Chris breaks down how microservices and aggregates relate in this video.  This video answers lots of questions about how Microservices are built and communicate. It also covers aggregates and how to pick what goes into an aggregate. This video does a good job explaining how Event sourcing works as well. This is actually one of the most useful videos because it covers Microservices and DDD concepts at a very high view level, giving you an overall idea of what everything means.  This video really helps tie many of the Microservice and DDD concepts together and will give you aha moments. microservices.io mentioned in the video half way through.


The Enterprise Architects Intro To Microservices Part 1 Kevin Webber

This video starts by covering some of the history of software design and how the industry arrived at Microservices. Kevin then covers how users expectations have changed since the internet was born and how these days people expect things nearly immediately. This video is an excellent explanation of why the microservice architecture is so important in the Enterprise world.

Kevin soon covers the history of SOA, how and why it was a failure because ESB was a single point of failure. This gives good coverage of Enterprise service bus failings. This video gives a great explanation of what a microservice is with a nice diagram. This is an absolutely excellent explanation of the Microservices Architecture or MSA.


The Enterprise Architects Intro To Microservices Part 2 – Jonas Boner

This is the second video in the Lightbend Microservice series. The talk begins at about the 3:00 mark, before is an introduction. This video starts with the differences between hardware in the past compared to today. Jonas talks about how microservices allow for better isolation between services and why this is good for preventing entire cascading system failure when one service fails. He then compares Microservices to the Titanic and how microservices allow natural bulkheading because of their isolation by nature. This isolation allows for self healing microservices.

Why Asynchronous communication?(15:00 mark)

Jonas then talks about asynchronous communication, why synchronous is bad and asynchronous is better. If you are wondering why everyone is saying you should use asynchronous then this video gives an excellent explanation with a nice diagram. You shouldn’t always use asynchronous communication, you can also use a Message Broker and pass messages.

What is microservice state? (~26:00 mark)

Jonas talks about microservices should own their state, they should own their data or database that is. This is one of the most important points of Microservices. One microservice should not reach into another microservices database either to write or read. He talks about the fact that there is no such thing as stateless architectures (~28:00 mark) scammy buzzword.

Bounded Contexts (~29:00)Jonas talks about bounded contexts in relation to microservices. Event Logging and Event Sourcing explained(~31:00 mark)


The Enterprise Architects Intro To Microservices Part 3 – Jonas Boner

This is the third video in the Enterprise Architects series. This video starts out by giving a good description of microservices and how they should work. Jonas talks about how microservices are distributed systems by nature and the sort of things that need to be considered when designing your architecture. Jonas makes the point that no matter what in a microservices system you will be dealing with stale data and inconsistencies and that is just the way it is. Inside data vs Outside data (~10:00 mark) this is a good concept to understand. One microservice communicates to another it wants something done via a command.  Commands should have a side effect. The challenges of microservices (~11:30 mark ) Service discovery (~13:00 mark) is covered. Anti-corruption layer discussed (~16:15 mark) Api gateway discussed (~17:00 mark) Communication challenges discussed (~19:00 mark) Integrating with other systems discussed (~21:00 mark ) Circuit breakers explained (~22:00 mark) Back pressure explained (~24:32 mark ) Securing microservices discussed quickly (~26:00 mark ) Saga Pattern discussed (~35:45 mark) More about Saga pattern here.

Books listed in video

Reactive Microservices Architecture: free O’Reilly report by Lightbend CTO Jonas Bonér

Developing Reactive Microservices: free O’Reilly mini-book by Java Champion Markus Eisele

Domain Driven Design Resources

Domain Driven Design Learning Resources

Domain Driven Design and it’s related concepts can take some time to understand. Below are links to articles, books and videos I have found helpful.

Articles

Here is a free guide to Domain Driven Design written by microsoft.   This guide covers CQRS and Event Sourcing complete with an app that can be downloaded and inspected while reading the guide. This covers bounded contexts and suggestions for finding them and much more. This is an excellent free source.

Using Aggregates and Factories in Domain Driven Design.

Aggregates & Entities in Domain-Driven Design

A little more information about aggregates

Effective aggregate design part 3 vaughn vernon

Effective aggregate design series vaughn vernon.
An introduction to event storming: The easy way to achieve domain-driven design
Modelling Reactive Systems with Event Storming and Domain-Driven Design

Domain driven design isn’t always the best design choice for all systems. This article details the many reasons why.
Why I don’t do Domain Driven Design. 

Tactical domain driven design. More information on domain driven design.

Domain Driven Design Reference Definition and Pattern Summaries.

Video

Domain Driven Design the good parts Jimmy Bogard


Eric Evans — Domain Driven Design Tackling Complexity in the Heart of Software


The Art of Discovering Bounded Contexts by Nick Tune

Finding your domains bounded contexts is an iterative process. In this video Nick covers some of the ideas behind this iterative process of mapping out your domains bounded contexts.


Domain-Driven Design: Hidden Lessons from the Big Blue Book – Nick Tune

Nick tune is funny. This is a really good talk about DDD Domain driven Design.

Programming resources

Dependency Inversion vs Dependency Injection vs Inversion of Control vs Programming to Interfaces

Dependency Injection is evil.  The downsides of Dependency injection.

You don’t need to know dependency injection. An article about dependency injection with Javascript

SOLID Design Principles Explained: Dependency Inversion Principle with Code Examples

Pros and cons of Dependency injection.

Useful software

Apache Archiva™: The Build Artifact Repository Manager

Apache Archiva™ is an extensible repository management software that helps taking care of your own personal or enterprise-wide build artifact repository. It is the perfect companion for build tools such as Maven, Continuum, and ANT.

Archiva offers several capabilities, amongst which remote repository proxying, security access management, build artifact storage, delivery, browsing, indexing and usage reporting, extensible scanning functionality… and many more! Get the latest updates, follow us on twitter @archiva.

 

Event sourcing and CQRS resources

Articles

This page from the Lagom Documentation explains why Event sourcing is useful. Advantages of Event Sourcing

Exploring CQRS and Event Sourcing This link is from a Microsoft project and is an excellent resource about CQRS and Event Sourcing. It walks you through the entire decision process of breaking down an entire application domain with basic Domain Driven Design concepts. It is very thorough and a great read to help you understand what goes into CQRS, Event sourcing and breaking your domain into smaller more useable chunks.

CQRS increases consistency.  This article is another good short argument for why you should use CQRS.

CQRS Documents by Greg Young

CQRS Clarified by Udi Dahan

Message brokers vs Message buses These two sound the same but are different this article covers the minor details.

Books

Patterns, Principles and Practices of Domain-Driven Design by Scott Millett and Nick Tune This book covers Event Sourcing and CQRS as well as all of the other principles of Domain Driven Design. The nice thing about this book is it has code examples, the code is C#, but you don’t have to down load it to view it and basically follow along. The examples often come after long explanations of the concepts, if you have time or know C# you can download and try the example code, a nice extra if you ask me.  This is one that stays in a pile next to my desk.

Videos

Greg Young – CQRS and Event Sourcing – Code on the Beach 2014

Greg tells some great stories that relate to why CQRS and Event Sourcing are useful and gives interesting insights into use cases. For many of us who have been doing the old fashioned CRUD architecture of storing and reading everything from a database, this video will make sense of why that was a bad way of doing things. After this video you will really want to dig into CQRS and Event Sourcing in depth.


CQRS and Event Sourcing with Lagom by Miel Donkers


An Introduction to CQRS and Event Sourcing Patterns – Mathew McLoughlin

In this video Mathew explains how an Event Sourced system that utilizes CQRS works. One thing covered is why having separate read and write data stores is a good idea and how it works in an abstracted way.


Event Sourcing You are doing it wrong by David Schmitz

I like this video this guy is funny. David quickly covers Microservices, event sourcing and other Domain Driven Design concepts, tying things together in a very entertaining animated and funny way. This is one of my favorite videos about event sourcing, it answers a lot of questions and makes many good points. This video is worth watching more than once.


Allard Buijze – Talk Session: The Inconveniences of Event Sourcing

This video has some good abstract information about events and event sourcing in microservices. It points out some of the issues with event sourcing and how to overcome them. Allard covers the types of Events, commands, events, queries and how they are used in an event driven system. The most interesting and for me useful part of this video is the part about GDPR and how to comply in an Event Sourced system at about the 38:00 mark.


Martin Kleppmann — Event Sourcing and Stream Processing at Scale

AKKA resources

As I find useful resources to AKKA I will list them here.

Links

Akka Documentation. The documentation is a great place to start.

Slideshare Akka Microservices. This slide series shows the related DDD concepts and how they relate to AKKA and Scala.

Here is a link about why you shouldn’t create too many akka actor systems in your application.
Akka anti-patterns: too many actor systems

Reactive microservices with Scala and Akka by Vaughn Vernon.

Books

Learning Akka by Jason Goodwin. I like this book because it is small and to the point. At about 250 pages this book jumps right into AKKA, it doesn’t tell any stories and the examples are concise and to the point. This is also a great starting book for Java developers looking to get started with Akka because the author shows how to do everything with Java then with Scala.  What immediately grabs your attention as you are reading this book is… how much more code it takes to do everything with Java. <– And that is why I don’t Java anymore. Java is like writing a novel to describe a page. This book mostly covers the basics of AKKA it doesn’t go into depth about all of the AKKA features and abilities. This book is just a nice, clean, overall introduction to AKKA with Java and Scala.  If you are new to AKKA this should be your first book.

AKKA concurrency by Derek Wyatt.  This is an older book, however it is still relevant. This book is  kind of long at over 500 pages, but it digs into how AKKA actually works.  What is nice about this book is it starts with an example and follows through with iterative changes as the book proceeds. The example is of a plane and flight crew and how all of the parts ( actors ) of the plane and crew interact to make the plane work. This book is more advanced and in depth than Jason Goodwins book, but I feel it explains the reasons behind what you are doing with AKKA. I’d read this book after reading Goodwins book, as it digs a little deeper into things giving more info on how AKKA works.

Scala resources

Scala links

Here are some Scala resources I have found helpful.  I’ll be adding to the list as time goes on. I have books I have not had time to read which I will list later, I’ll also list new resources as I find useful ones. This serves mostly as a collection of notes so that I can remember what I read and where I read it so I can find it again later.

The number one place to start learning Scala is the new Scala book   written by Alvin Alexander. Alvin does an excellent job of explaining Scala concepts.  The Scala tour should link to the related parts of that book.

Here is a link to the Scala Api, these are the classes that make up the language. This is the best place to get a peak under the hood of Scala and find all of the methods of a Class or a Traits signature. You will see there are links to the Library API, the Compiler API and the reflection API.

allaboutscala.com This is an excellent website with tons of tutorials and information about Scala.

Scala Glossary of Terms. Here are many of the terms you will encounter when using Scala or reading about it.

All about Dependency injection in Scala.

Here is more information about dependency injection in Scala.

Simple Dependency injection in Scala without special frameworks.

Functional programming approaches to dependency injection.

Here is another article about functional programming and dependency injection with links to more information.

More about dependency injection and Functional programming vs OOP. How to Trick OO Programmers into Loving Functional Programming

Scala is full of lots of magic, magic that can make it hard to learn because you see things done in so many ways in so many places with often little to no explanation . 4 Fun and Useful Things to Know about Scala’s apply() functions   So much of what you will read assumes you know Scala inside and out and upside down, like the Lagom documentation here where it states “As you can see, the sayHello method is implemented using the apply factory method on ServiceCall” Which you look and look and there is not an apply factory method to be seen anywhere, so you have to stop and do some google work to figure out what is going on. This little line of magic is what the documentation means ”

 ServiceCall { name =>
    Future.successful(s"Hello $name!")

It is assumed that you know that in Scala anonymous functions always contain a hidden apply method etc. like the bottom of the linked article mentions.  The main learning curve to Scala is all of the 10001+ things you have to remember about everything everywhere, my brain just does not like to memorize everything about everything, it likes to solve really hard problems.

Scala Books

Programming in Scala 3rd edition.  By Odersky, Spoon and Venners these are the authors of the programming language so this is one of the more in depth books of about 800+ pages and covers all parts of Scala.  This is a good book and basically a must have reference you will want to look back at from time to time. It has many small examples that can be run in the command line. You can also create scripts and call them from the command line, which is how I did the larger examples instead of typing in all of the code.  This is an older book but it is still 100% relevant in case you are wondering.

Programming in Scala 2nd edition Wampler & Payne. This is another good book that covers Scala slightly differently than the Programming in Scala by Odersky, Spoon and Venners.  This book covers Object Oriented programming in Scala as well as Functional programming. The book is almost 550 pages long, not too large or small. It also covers the type system fairly well. I like it’s discussion of implicits, these can be confusing if you come from other languages.  This is also an older book but it is still 100% relevant.  This is one of my more favorite books.

Scala Cookbook by Alvin Alexander. I feel this book is one of the Scala must haves, this book lives on my desk.  Alvin has an amazing ability to explain complex subjects in simple terms that every day developers can understand.  This book is almost 700 pages long, it is older too, from 2013 but it is also 100% relevant. This book is so wonderful because it shows hundreds of ways to do things in Scala. This is a wonderful book to have while learning and long after you have learned Scala. Many times while learning a new language you will ask yourself of others “how do you do this in this language”, this book has all of those types of answers.  This book shows how to do so much and is full of so much useful information, this is one of the must haves.

Functional Programming Simplified by Alvin Alexander. This is a wonderful book of 800+ pages that tells a story about the pieces of functional programming, breaking down the subject into over 100 small 1 to 5 page chapters. If you want to understand functional programming in Scala this is the best place to start. Even though the book is over 800 pages, the short chapters along with the authors unique ability to express complex ideas in simple terms made this programming book fun to read.  I found that the small chapters were perfect for when I only had a few minutes to read. I honestly wish more books were written in this fashion.

Functional and Reactive Domain Modeling by Debasish Ghosh. This is another good book about functional programming in Scala.  At under 300 pages it is concise and to the point.  This book cover Scalaz and almost makes you want to use it just from reading about it.  It is best to read this book after the Alvin Alexander functional programming book, this book is more advanced.  In this book the author covers why you would want to use a functional paradigm and makes a strong persuasive argument for it.  Overall I really liked this book and it is a good addition to any serious Scala programmers library.

Video

Scala best practices I wish someone’d told me about – Nicolas Rinaudo

I wish this video had been around when I first started learning Scala it answers a lot of the questions I had at first. This is one of the best videos about Scala, so much useful information here.
Nicolas gets right to it in this video

  1. Array Comparison ~2:00
  2. Type Annotation ~3:55
  3. Unicode operators ~5:30
  4. Enumerations ~7:20
  5. Sealed Traits ~8:45
  6. ADT Algebraic Data Types ~12:20
  7. Case Classes ~15:50
  8. Custom Extractors ~18:45
  9. Structural types ~20:55
  10. Exceptions ~24:05
  11. Errors ~29:50
  12. The return Keyword ~31:45
  13. Implicit conversions ~33:55
  14. Implicit resolution ~36:30
  15. String concatenation ~39:45


Scala: Beyond the basics with Christopher Batey

This is an excellent video, this will clarify quite a few things for new comers to Scala.

This video covers how to rely on the compile more and libraries less. At about 3:30 he hits on what I noticed. I have learned like 7 different languages and thought I would just learn Scala. Well Scala is so much different it is like learning to program all over again. With the OOP and the Functional capabilities along with no sort of suggested best way to do things, it makes the beginners head roll, especially when you then discover there are multiple ways to do things. Even after you learn Scala for a while you have more options and more things you can do, so you have to come up with your own rules and make sure you and your teams stick to them.

The first 11 minutes of the video discuss expression vs statement based programming. At 11 minutes Christopher starts talking about Function composition which is the main concept of this video. This video is an excellent introduction to what functional programing really is. Type Aliases covered at 12:00 mark, I googled for a while trying to figure this out when I saw it, I got very little luck. The shenanigans of learning Scala is what inspired this website. Traits are discussed at ~12:30. At about 15:00 Christopher talks about repositories using traits. Traits are used for many things in Scala.

At about 16:00 the talk about functional programming begins.

  1. ~18:00 Curried functions are explained
  2. ~20:00 Function Composition explained
  3. ~23:15 Currying and Partial function application
  4. ~25:00  Scala Class use cases
  5. ~26:30  Implicits
  6. ~28:15 Higher Kinded Types
  7. ~39:15 Implicits conversion
  8. ~45:30 He gets to how it is harder to learn Scala than other common languages. Scala is a really different kind of language. I like it most for it’s conciseness. But learning it requires learning many programming related concepts you don’t normally learn or think about. Scala requires that you and your team have MUCH MORE DISCIPLINE and you have to force yourself to stick to a paradigm or else you will get a mess.

An excellent book that covers the subject of Functional programming and function composition is Functional and Reactive Domain Modeling by Debasish Ghosh  The book is well written with clear language in less than 300 pages it is all about Functional Scala with code examples. The book covers many subjects, it is one of the books I keep in a stack next to my desk. Check the table of contents of Amazon.

Modular Software design

Build it Modular!!!

Those are the words I will always remember.  About 5 years ago I was talking to a retired Engineer in South Florida about an idea I had for an app at the time. His response was “Build it modular!”.  At the time it was already too late I had built the app and launched it and watched it flounder and fail.  Those words haunted me and lead me to ultimately research modular software architecture in depth. I was determined to never again build a Monolithic Big ball of mud.

One of the main reasons the app failed was because every time I would fix a bug another would popup. I had built a monolithic Big ball of mud ,  It was the way I had learned to build programs in college and books etc.  I had even gone as far as creating UML ( unified modeling language ) diagrams and EER ( enhanced entity relation model ). The problem with those is you change your mind while coding, so you have to also change your UML and EER or it gets out of sync with your code and database.  It was thought to be helpful to have the UML and EER’s match the actual code and database as basic documentation of the system for lead engineers.  I now prefer agile modelling methods.

We don’t learn modular programming.

Many college degrees, online courses etc. don’t cover modular software design. Most of the focus is on programming and making things work. While learning to program, most of the code we learn from as examples is fairly small. Inevitably as developers at some point we start building side projects. These side projects, especially when we are just beginning, start out as simple ideas and slowly grow. Eventually these projects turn into “Big balls of mud” where the code is tightly coupled and nearly impossible to add to or change.

How to find the modules of your program?


One subject that any developer aspiring to reach the top should invest time in is Domain Driven Design (DDD) . Domain driven design sounds complicated at first with all kinds of buzzwords like “Value Objects” and “Bounded Contexts”, but it helps you break down large applications and create a language everyone from the business leaders to the developers can understand. This breaking down of the domain ( aka your project) into smaller pieces, naturally leads to a modular design, but it is how you wire it all together that makes the difference.

By using the concepts of DDD you can more easily discover your domains bounded contexts ( aka modules). This is not always easy and you won’t always get it right the first time, it is an iterative process. Within each bounded context ( module ) you have aggregates, these are interacted with by calling api methods that work with each other to perform the tasks of the module.  These modules are what we consider microservices when going the microservice route. Finding your aggregates can be sort of hard.  Here is a link to more information about aggregates. Here is another helpful link about aggregates

How do modules work?

Each module should have one and only one responsibility, it should perform one single function/operation. The login module shouldn’t contain logic to also register a new user for example. Each module should be responsible for and have 100% control over it’s data. This means that one module should not access the data of another module. You may have a user_authentication table for example that stores the users password and email. Your system should have a UserAuthentication module and the login module should use it.

How to communicate between modules?


Modules can communicate  via (application programming interface ) API interfaces. These interfaces simply consist of commands you can send to the module to perform tasks. Basically the API interface is a file, a list of functions, a class( depending on the language/framework or your style ) a main method, it is the router of the module routing requests ( calling code ). The API Interface allows you to contact the aggregates of modules to get work done.  If you have ever created a class with public methods then you have created an API. The public methods of that class are the Application programmers interface for that class.

In Domain Driven Design these API Interfaces are known as aggregate roots and the root is made up of aggregates. Aggregates do things, like the methods of an API do things.  These aggregate roots are how you interact with modules/microservices to complete tasks.

There are many ways to integrate your modules ( make them communicate, glue them together ) into a larger system.  There are message queues, RPC (remote procedure calls) REST  ( representational state transfer ),  actor frameworks and more. Which system you choose depends on the circumstances of your app.  The main thing is finding your bounded contexts within your domain and splitting your app into modules.

For more information about how microservices/modules can communicate see Chapter 11 of  Patterns, Principles and Practices of Domain-Driven Design by Scott Millett and Nick Tune   Another good source on how microservices can communicate is Chapter 4 of Building Microservices by Sam Newman.  In a future series of blog posts I will cover how to use AKKA/Lagom to build an example app and explain the concepts in detail.

What is the goal of modular software design?

The main goal is to not create a Big ball of mud monolith. The idea is to divide and conquer, to be able to chunk our larger monolith app into smaller more manageable pieces, that can be split among teams and developed autonomously then combined into one working system.  If we can properly find our bounded contexts and make those our modules, we can turn those modules into microservices. 

Modular is Microservices

Basically building modular is building microservices.  Microservices are hard, they are essentially a distributed system. With microservices you have to deal with many things like Service Discovery, Load Balancing and much more. With a monolith your system is tightly coupled and hard to scale. What is the happy medium? Surely someone has thought about all of this and figured it all out.

Over a series of posts I will cover how to find a domains bounded contexts and how to translate that into Scala and AKKA/Play/Lagom Framework code. The problem I’ve had most when learning all of these concepts is, how does all of this work together? How do I break the system down then write the code in Scala and have it all not fail later? In the series I will break down an entire Social Platform and describe the why I make the design decisions I do. I will show what structures in Scala relate to the concepts of Domain Driven Design.  Sometime next year I will complete the Social Platform and offer a free partially built Scala app that interacts with the Social Platforms API to demonstrate all of the concepts.

Related Resources

Reactive Microservices Architecture: Design Principles For Distributed Systems  This is an ebook that covers the concepts mentioned in this article.