← All episodes Episode #79

Domain-Driven Design and Moduliths with Oliver Drotbohm

πŸ—“ May 06, 2023⏱ 1h 02m
Domain-Driven Design and Moduliths with Oliver Drotbohm

About this episode

We chat with Oliver Drotbohm about what Domain-Driven Design is and how it might intersect with Microservices, Monoliths, or Moduliths.

Resources & links

Transcript

Generated automatically by Spotify, so expect the odd misheard word. Select a timestamp to play from there. Download (.srt)

Read the transcript

0:01 Welcome to happy path programming. I'm Brew cycle. I'm James Ward. All right. Well, welcome everyone. Today, I'm excited to have with us all the drug bomb and you we've interacted for over a decade. You've been up here to Crested Butte to the Java Posse round of you said twice, right? Why is yes. 2009-2012 - awesome and so great to have you on you, you work on the spring team, currently, right? Yeah, thanks for having me in the first place. Yeah, I've been an engineer in the springtime for over a decade now, so, I've done a couple of different things primarily the spring data stuff. So all the repository abstractions in there. That's been what I've done with the a team of four or five people. Now nice.

0:49 But yeah, I have moved on into some different topics architectural related topics recently, right? And that's actually one of the things that I'm really interested in kind of picking your brain about because you've done lots of work in domain Driven design. Yeah, so, I mean, the spring data projects are the repository abstraction like, like tightly connects to that there is this concept of a repository, in domain driven design, kind of, simulating a collection of Aggregates basically, and being able to select a subset of those Aggregates through an API and we built a Java programming model around this, that's become pretty popular. I think it's the third most Downloaded spring project like we want me to system.

1:42 Wow. Okay, so to get started, I want first, I want to talk so this mug. Yeah. Which our listeners can't see but our listeners campus very nice muggy but has your name on it has my name on it so what happened and this was to the Sea 2013 so ten years ago OK and Eric Evans invited a group of us to what he called the DDD Summit. And this was based on some of the events that I had here in Crested Butte because Eric had come to least a couple of them. And he said, oh, I want to do something like, I see how it works. I want to do something like that around domain-driven design. So, I went with Barry Hawkins, who least for a couple of years, worked with, Eric to try and, you know, turn domain-driven design into.

2:36 I think, I think, I mean, I think they were looking Looking at creating a training and consulting firm around it. And I think that what I came away with was that Eric felt at the time that it just he was disappointed that it hadn't gained traction really had the time. It wasn't, you know, all this his book, well his book had been so this look like before this. Oh yeah, the book had been out. It's sometimes it's po 2004 actually. Okay. So It's a book for like 10 years and it's like oh was it taken off wasn't taken off and now let's do a summit. Yeah, it was. Well, yeah. Maybe that's what he was hoping for and and I think he did want to ask, you know, all right.

3:23 You know what's what should we do about this? It's, you know, it's kind of like maybe what John to goes has been doing with Scala recently and he he was just, you know, disappointed at its lack of traction, but now Now, it seems like in the last couple of years, probably longer people are all about domain driven design. And can you tell us like first, like, what is demand-driven? Well, yes, definitely what I want to hear like what is, what is the basic? Cuz why I read, you know, a little pieces of the book but not this. I never really immersed myself in it. So, you know, what problem are you trying to solve with domain driven design? So I can give you the story. How I discovered the Basically, so it's not sure I think it's it's been like one of the books that has most fundamentally changed, the way I look at building software, or yeah, both on the let's say higher level point of view is like how which systems to build where the boundary is, like, that kind of stuff. And also on the, let's say more down to the code aspects, like the content Concepts, and building blocks, he Eric mentioned in the book.

4:37 So it's Be two big Parts. One being this strategic design which is all about, like, which systems do you actually build? Like, what Scopes do you have the famous bounded context notion, how they interact with each other? How they relate to each other? Like, who's controlling like certain parts of the model and kind of person like architectural decisions. Right? Exactly, so it's kind of that. See that see bigger systems kind of organization part of it. The book. Ever starts with like the concept of ubiquitous language. So trying to put the business language into code and also describes a couple of patterns. I'd say that you find in code that. Yeah, which you kind of use to organize your code, Implement, certain tasks or responsibilities, like, like, scopes of consistency, and whatnot. So, it's that's the technical design part and a lot of people actually stop when, when they I passed this because the book is pretty pretty big, actually, there's a lot of Concepts in it. So yeah people often just maybe take the easy ones and and I have to admit I mean I've started as a junior developer back in the days and those patterns were the things that Drew me to the book because it was immediately useful for me in my day-to-day work, whereas the other stuff is kind of like, of course, architectural stuff.

6:06 That's important as well. But as A day-to-day developer, you're kind of not really in the position, put in the position to decide, okay? We change the whole system's landscape organized teams around it. But hey, if I can improve the code that I write to some degree, by applying these patterns, that's a win in the first place, right? And that's what kind of Drew me to the, to the Buddha's, almost like a inherit scale to the problems that it's trying to solve is that there are some things that apply to an individual developer on a team. And can be very useful in that context and then there's other Concepts that would apply kind of more to some someone in a architecture role that is working with many teams and thinking about the the system as a whole and that sort of thing that that it's exactly. I mean it's a kind of a holistic view or like approach to software development and allows you to like depending on what kind of your role is in an organization or as a consultant and what kind of people you talk to, you can always find Thing to kind of improve the current situation whether that's like a messy code based and you try to like organize that a bit. But if you like talking to teams or the HR department, that had this kind of setting up the teams to actually solve problems overall, then you rather like try to fine tune, those like, with all the Conway's law stuff and what have you? All right.

7:32 So it's it's kind of, it's such a big thing that you always find something that you can take forward to. Like improve the software you build. So yeah. So can you give us the essence of? I mean I don't know maybe we should start at the individual programmer level. How what? How does that change? How what, what, what what mindset changes do you experience when you're coding? So what it did for me was that are they did a key piece. Was that kind of you Have this ubiquitous language and to be able to connect to the business and eventually provide value. You have to talk the language of the problem or the problem space and by that the people that are busy with the problem space. So I was like really into naming things right. How do you find good names?

8:29 How do you, how do you make sure that the gap between the problem and the code is as small as possible and that's kind of to find the Right. Abstraction levels getting away from like technical Concepts to, let's say, more higher level Concepts, to be up, just because I was like the promise of object-oriented programming, right? We can create our objects to represent problem domain things. Sure. And I mean this different languages like give you different opportunities to like do that right to build not saying dsls but rather like write code that has has expresses the the problem. Maine. But this at least like in the code bases, that I've see at customer projects.

9:15 For example, there's often a lot of room for improvement to actually do that to just basically name things better and by that make things more expressive. There is this this great talk by done, by Johnson the value objects talk. I think if you Google it on this end, one on in focal line and put it in. In Tokyo has a recording. I can find out the link. Basically takes it could be that's very technical and driven by Frameworks and what have you? It's about like money, exchange, and exchange rates and he just adds tiny things, like value objects to the code base and ends up with a piece of code. That's just like reads. Like the actual problem statement and that's even Java, right? So it's kind of like it's not like the most the most convenient language to build. Let's say an API that's not like with curly braces and what have you you don't have all that powerful language soon? X that you haven't Coughlin for it sounds. All right, with making much more shape. The, the text that you have to write together data model and there's who know more ceremony maybe in Java for ya. De tomate.

10:22 Right? Well, now, when you say value object, is that could that be like? Well for example, I mean, the language is that I'm studying now have a focus on immutable data structures. Is that is that what you would call a value object? Yes, sure, I mean, It's like representing domain Concepts that are values and that allow you to like performed certain. I'm not not business operations. But again, speak the language of the business. Let's say that the classic example of an email address, right? It's not just an arbitrary string that you carry through the system, but it's actually it have followed some structure, it has a local part. It has a server part and you can access those and you can do things to that. And if you hand this over to some other piece of code, that other piece of code can be Sure, that it's structurally an email address. It's not just an arbitrary string but it's that particular domain concept, right?

11:16 So you don't have to validate it anymore, you get that. You actually just use the type system to express the main concept so that the compiler help you like check the correctness of your of your application code and and the convey to people reading the code, what the business-oriented side of it is Look at this is like strongly typed method parameters like string, first name String, last name, String, email address. And then you mix up the, the order of that stuff, I'd rather have like explicit like name class or an email address class or what. So the is the essence of this that we have business needs that we're trying to address. How do we map those business needs to the code that we're actually writing in a way that that has cohesion. And it also sounds like what some people have been calling. Data structure oriented design and that one because yeah, I mean it's when you have the immutable data structures and you go well, what should they be? They should be something that relief. Well, at least maybe my interpretation is they should relate to the problem to me.

12:23 So your data structure should be something somebody can look at and go. Oh yeah that's those are the pieces that we want to manipulate the data starts just like the term at least in the Java world. It's a bit of a tricky one because it's Data structures usually understood as something where you have like Getters and Setters like this Java Bean concept on it, which kind of is a bit. Subverting the, some ideas of DD because you wouldn't want to expose those internal structures to your calling code. But rather basically capture State when you create an instance. And then that instance is able to answer questions around the domain rather than basically handing out all the, the the values that it consists of So capsulation idea.

13:11 Exactly. So that's also, a reason that records that have been like right at it quite recently to the Java language they are a bit of a special thing here. So some people really dislike them for exactly that that fact that they kind of says it goes against what they including me, have been taught all this time is, oh, you want to have variables inside of these data structures and you want to protect them through encapsulation etcetera. This idea of a record where The thing is exposed is definitely a mind shift, but once you see it, then you go. Oh yeah, we don't actually need encapsulation. If you've got immutable data structures, it's kind of a neat and need tool where you fall, it's especially like these single value objects, like an email address or what have you, where you at some point especially at the boundaries of your application. You need the raw value again, right? If you wanted, like serialize it into some Json or what have you or have to actually put it into some database column? But you you actually get or you are able to express the concept in a very concise way so that you can then have that particular type that you carry around that's matching the business requirements of basically just the email address format whereas like before records you'd have to create a class Final field.

14:31 Constructor equals hashcode, write all this down or let basically let have your IDE Write this all into your, or using extended to go like and whatever it is. That's causing a lot of boilerplate hop and in turn cause people not like using these classes because it's just so much boilerplate code, right? So factly, and it's leaking in. It's leaking. Some of the system needs into the business domain space, which I think domain-driven design is trying to say that. No, let's let's keep our business domain focused on the business domain. And at Some point. Yes, you need to take that object in, serialize it, and there's different system needs that may come into play, but let's keep that as like a separate concern. Yeah.

15:19 So it's, I guess it's kind of you kind of have to get a feel for when using a record is like, or that record Concept in Java is the right thing for simple values. It's perfectly fine. Just that if you basically try to listen, you have your entire customer modeled as a record just because it's immutable and it's kind of still. Yeah. No, it's a, it's a definitely a mental shift. But once I mean, once I started seeing I'm going, oh yeah, of course, of course, if I was to ever rewrite, one of my Java books, it would be records unless you're forced to not use records. And usually that's only an efficiency issue. Yeah, so an example of this is Maybe You you can I think often maybe pre domain-driven design and and Adoption of that.

16:16 Oftentimes, your data layer would model how you needed to store the data in the database. And somebody would look at your data layer and be like, if somebody is looking at it from the business perspective, be like, why is it organized like this? And the answer would be? Oh that's because that's how the database needs it to be organized but in domain driven design, you say, no, let's keep the layer. For the business oriented totally around the business needs and business domain. And then we can transform from that layer to the the database. The way that the database needs the data actually store, right? And if you use a different kind of database, then you use, then you can change your triggering condition hard water that having to change into the structure. Yeah. I guess that's the heart of what you just said, is the, she is like, hidden in these or is also represented in these like onion architecture and hexagonal. Sir, approaches, where you have your core domain, that really focuses on, like, trying to write as pure as possible code that represents the domain.

17:16 And then you have some kind of adapters or rings in onion architecture, the translate that into like the infrastructure right into the database or the UI, the way the wi or basically a. So what now early I can't remember the phrase you use but you were saying We want everything to map to, you know, as much as possible to the business domain. What about like in functional programming? We have all of these kind of bowl for functional, its low-level primitive, things like the map and the fold, and the things like that, which allow us to not, or basically, it allows for greater code reuse and greater reliability. You know, we're not having to write everything by hand for writing at a slightly higher level, but it does that. Hmm, intrude, on some of the ideas and domain driven design, or are they compatible?

18:21 That's an interesting question, because I've come across this quite a lot when I've seen projects and awful. Also, like the projects I've been in whooping, have used libraries called way or like waiver. I'm not sure you've heard of that. I do not feel like it's basically they're trying to Um, transport. Some of the concepts, you haven't scholar into Java like a try, monat, and okay, it kind of it. Nudges you to write a bit more, functional code in Java and I've used that in a couple of projects to to some success. So it's all working fine. The effect it has on the code is a bit of a like a. I think I'm a bit torn on this one because you Zeus a language.

19:08 That's familiar to us as developers like, as you said, Bruce with, like the folds and the maps and what have you? That's not necessarily the language of the domain. In fact, it could even exactly can even, it could even like Shadow concepts of the domain. If you just a method of filter, like if you talk to a someone from the chemistry domain right? Is that when you say filter, do you describe what you try to? Keep or what you want to let through. So, it's cleaner inclusion. This, that's it. That's a just having that additional language in there. Can be like beneficial to people understanding that language and the technical language. But at the same time it's also a bit alien to business code to some degree.

19:57 So yes, that's really my question that the names the names are oriented around the actual like mathematical functions. Mathematical Concepts not oriented around the business and yeah, because you talked about the common language, and so that's what made me think, okay? I mean really, yes, when you're using the filter, you say, alright? The essence of the filter is not the action of filtering which is standardized and debugged but this little usually Lambda or whatever function, we pass the describes, what we're filtering for. And so that, you know, I think you could say okay that's the Language of the domain but you're just not used to having these these higher-level tools that functional programming provides for you or the error handling models.

20:52 That functional programming. I think they are handling. One is a really interesting example because if in your domain model you're getting the data from a database or a micro service or whatever then that's something that may fail. And do you put like the Try monad into your business domain. When the business domain doesn't care at all that the thing failed, right? It's just, and so that's, that's it. Seems like a place where it could easily leak in where you're leaking in the actual technical details into the business domain, what I found quite useful and it's often or that's also actually coming from Deedee and I see a lot of people like not doing. That is kind of modeling. Is error scenarios as explicit as part of the domain, right? So not trying to.

21:44 Okay, there's an exception or anything, or even that like a try, like an error result. It just said, okay, the let's say the request, the account request is just in some particular state that it that is like erroneous that that someone has to look at it or we have to perform so actions on it. But it's actually that error state is a valid state within the application. Right, within the software application of the contract application, for example. So that often like does it as a bit of a or is it was a bit of a switch in how people can think about stuff and not try to do? There's this exception that we throw and then we handle this someplace and we just display a message to the user and then they have to have to deal with it.

22:29 But rather, okay. This thing is it has a new state that represents a problem, right? So next time, yeah. Or you. Look something up. Yeah, I mean, you look up the name of a user and that may not exist. And that's a legitimate thing in your business domain. We thought go, we looked up the user. Uh, no. They don't have an account. Well, that's a totally legitimate. The example, I usually give there is like, if you have, let's say an e-commerce application and you have to keep track of stock of products, right? And then there's of course this easy way to Say, oh, I have four TVs in my inventory, and someone wants to order five. So I throw an exception and basically saying you can't order these five TVs. But what if we just like model this as like a perfectly valid State and then draw some conclusions from that that that overdrawn right?

23:25 So basically say okay dear people, we have to basically reorder stock, right? So make turn this into a signal that after like you you cross a certain threshold, You'd have to do other business activity to solve that problem. Cool. So it's yeah when it seems like the the easy naive approach is just a thread, the exception second, let the color deal with it the but that's not necessarily in line with what the business needs are because it could very well be that the business actually wants the person to place that order and actual that mean and that then they want to like you said have other business strategies to then two then rectify. The Oblem or something and that's exactly the point, right? We want to, I want to get the developers back to realizing, oh, there is a, in this problem, there's a business opportunity or at least some discussion to be had via. What should, what is the business want to do in this scenario?

24:23 Are we really reject that order like and why and isn't there an opportunity for us to actually improve? We can sell you three now and then the others will come because we're going to order them, you know? Yeah, I think this is it's so valuable to in the world is shifted in for developers. It used to be long ago. 20 years ago, when I was writing a bunch of Business Systems that there was the business, there is the business analyst and then there was me the developer and that business analyst was responsible for translating discovering and translating the requirements of the business to a specification. Haitian that then I would go Implement and it seems like that business analyst role has in some ways evaporated and now it's the developer who is having to understand what the business needs are and Implement them more directly. And maybe domain-driven design is the best way for developers to create that cohesion.

25:29 Cohesion across the movie Office Space was so pressing here because they have the guy who kept explaining. Yeah. I take the Quirements from the business people and then I bring him to the elevator to the developers. There's your yeah, there's your analyst, there's your business. Analyst, I have people skills and isn't that at the heart of the like agile software development movement. So it's like developers talking to business people and in collaboration basically build stuff that's useful. So, yeah, yeah, yeah. Instead of The throwing them over the wall and saying, yeah, built this and wait, that's not what I imagined that it was going to be exactly. The reason why I think that role has evaporated is because it was like the telephone game where there is this, you know, loss of information.

26:17 As you worked through that chain. And we've I think through agile and demand driven design discovered that, oh, let's just instead of playing the telephone game, let's just have the developers addressing that this will just give the Uppers, the people skills to talk to the customers. I mean, that's that's the role of modern business owners rights to, to Foster that translation and that communication. And I think there's still room for that skill, especially as like often developers are not that, that skill that and that but in anyone awesome time, you got business. Domains are incredibly complex. Sure. And yeah, asking always asking the developers to fully understand the business domain. Can has its own challenges. Yeah, that's work.

27:05 Yeah. So did we miss any big pieces of demand rig? Well, no, I have a question. I have a question. So I feel like we've mostly kind of danced around the low level stuff. Sure that. Now, I want to know. All right, so from an architectural standpoint, how do you attack? How do you approach a project from a DDD standpoint? How do you like Like start architecting such a thing. Well, that's a that's a broad question, right? Because then you're depending on like, what? What kind of role you're in and like, what stuff you're looking at, what what the context is in which you have to develop the application? What I've what I usually do when I'm getting, like involved in customer projects and they they asked me to help them architect.

27:54 Any kind of software is that I let them present their functional decomposition. In first, so like what are the big pieces? That what was your what does your system look like from in from like functional separation point of view, right? You often get like C4 model architecture. Diagrams from from Simon Browns C4 model, that is that one and that kind of helps us like a way to describe the business, the the business objectives and what they want from the system, or what they've built with this. System, I guess I mean, I just like basically started from the discussion from or there's an existing system point of view, right? If you want to help me understand that if you start from scratch, then I of course, think you have to look at the organization and their what kind of teams you already have, and what are they working on?

28:49 That might give you not like an ideal situation, but just at the state of the of the system you have and then the question is, okay, what do we actually want to build? Right? So what's, what's the kind of thing? What, what business value do we want to provide? And how does that fit in fit into the current Arrangement? Because, I mean, so you're out of work and so we have it on ways law then, yeah, I mean it's you try to align with that, right? Because there's no point in in being at odds with that and there's hardly any real Greenfield development and all anywhere. Because I mean, just a week after he started and you kind of just changed a lot of your Greenfield. Yeah, but that's kind of Dove. That's kind of the the the idea here and and it's of course it's a process, right? It's not something you.

29:37 Oh here's the thing. The way you do that it's you could there's like Brenda Leigh I better bone really nice event stalling right to understand what the business is doing and then trying to find those those individual pieces, get to the bounded context, basically areas of business of the business domain that have to be conflict-free in terms of the language. Which so when I say order and you say or do we mean the same thing but if Bruce says order e, might mean something different and then you kind of feel, get a feel for where the boundaries are or where you could put them in place reasonably well. So, because it's especially if you're new to a domain then it's always like a bit of guesswork involved and then it's just, I guess a question of how to establish Publish the boundaries in a way that they that you can basically good fences. Make good neighbors, right?

30:36 You put them in in place first but might be able to also tweak and alter them in, like, in a reasonable way so that it's not as expensive. So so an example, the select the order one is that if you if you don't Define your boundaries and the context that you're the everyone Seeing different things through. Ultimately, what you're going to get is an order object that some of the fields are for this business unit, some of the fields are for this business unit and some of the fields are for this business unit and domain driven design, would maybe say that that's a red flag that you haven't bounded the context. Well, so the I mean, the example is pretty great because the because you if you naively, look at this stuff and I mean, I've been guilty or I am still guilty of this myself, because when I built it, Example projects, they are usually very simplistic, right? And then you have your order, and then you have your inventory and then you have your catalog with your products. So it's very entity Centric and you're very, because that's okay.

31:43 The, my domain is very simple, right? My product has a price and that's it. Whereas, in the real world it just isn't as simple. Right pricing is can be the most complex thing in the world. And you have, like, tons of different aspects playing into this. And then the entire Pricing and product thing could become a separate bounded context the for. It's usually like shipment and invoicing that all touch order and customer to some degree, right? They all have a different particular view on the order, right? Invoicing is interested in tax rates. Shipment is interested in the dimensions of the product boxes or what have you but not in tax rates.

32:29 So you've Edit out the different different teams within an organization, they're going to have different needs on what an order is to them. And so, and so and domain-driven design, you you design, you don't, you don't try to assimilate all that into a uber order object. You instead say this is the order object for what this team needs, and this is the order object for what this team. Well, I would think there would also be an essence of an order object that is going to be this Same common for every team and then when they get that, they go all embedded in our thing and we'll do our stuff with it. And then when we're ready to pass it on, we just take the embedded part and pass it on to you is that it usually is like one of these like systems or like parts of the system that kind of establish the identity of something and then the other like systems or parts of the system, refer to that identity so that you can of course go.

33:31 Correlate. The different ideas of an order. Quote-unquote to the same logical thing. But I've seen like projects where you didn't have even have like any kind of shared information at all. It's just like all just an identifier and then everyone else has their has their the info that they need and then just like in and eventually consistent way exchange. Oh, I've done an update to some to that thing that I have and everyone else is just Pulling out the things that the aspects that they, that they are interested in because they're usually, of course, is some overlap that doesn't necessarily mean that you have to kind of use a shared data structure or anything like that. And all of this should be tangential to the actual storage mechanism.

34:17 That's required by different parts of the system. So I think that that's probably an important shift for me, and what I've gone through is I would initially long ago. Design a system about how I wanted to store the data. And with domain driven design, it says, no start with the business needs and then and then figure out how each piece of that needs to actually store the data or pass it to another system or whatever may be present. Because if you do that you can then actually do what you wanted to do in the first place. Choose the best data store for the problem at hand. Yeah it's so whether it's a relational database, some documents to our graph database. If you have two recommendations, What have you? So the argument is as which is, I came across this recently because the argument is oh, well this allows you to change the database and people were going, you know what, that never happens. Yeah, so that's not a good but it sounds like it's a the better argument is okay, we're abstracting that away so that we don't get muddled up with those details when we're talking about the concepts from the business.

35:31 Is standpoint. It really seems like we're trying to bring programmers away from all the you know low-level stuff that they think about in terms of solving this problem and just educating them in. Hey, you're solving a real problem for real person and we should keep. We should talk about that problem in those context and it seems like that's kind of what it is. That mean that this coupling decoupling Russian is something that comes up in a lot of discussions, I have with teams because of course, I mean, there is this, this notion in domain driven design that you had that discusses, before that you want to like be in. Do you have your pure domain code and then you would want to add at the boundaries of your application. You kind of map that into some infrastructure right into some database at the same time and onion architecture, for example, kind of suggests that you have this outer ring. NG and then in that ring you have your apis that produce Jason and you have your database that that's a map onto a database table.

36:40 I don't really like that picture too much because there's a significant difference in the translation mechanisms, as you said, Bruce in recent applications, The application team usually also owns the data store, right? And there is a there is a direct connection or you can actually make a more direct connection to that data store. You can simplify the mapping you couldn't even, let's say, go ahead and avoid an intimate intimate, an additional layer of mapping because that all also comes with with complexity. Whereas let's say for the API, right? If you, if you expose something to third parties, you're not controlling that Model right. That that thing. And you can't like arbitrarily change it.

37:27 Whereas if I have a customer and the customer has a first name. And the last name, then I want to have my table to have a customer and the last name field. I don't want any kind of mapping in between so that the thing in the database could be called something different because that's all just like cognitive overload that I have to deal with then, right? So I want these models to be Clothes from, from some point of view, I still want to make sure that I can use my domain code without the database running without the database in place. But that's a different. That's a different kind of aspect of the decoupling like discussion, right? And I definitely think that you can have different trade-offs, depending on whether it's the target. The target model is something that you control or something that you don't control in the API case for which It probably makes makes a bit of sense to have an additional mapping step in between, but at the same time, of course, if you have the customer has a first name and a last name, there will be a first name and the last name field in the in the Json representation. Right?

38:37 So yeah, it's kind of a, it's a more subtle discussion in like, oh we our domain is pure. And then we decouple this completely from our database because you're too far with with trying to create isolation when you may not need it. Yeah. And it's basically it took this off from from Bruce comment about the we want to exchange the debate was new Bruce or was it oh, you might change the database and that's hot. That's not. Not really, it's not going to happen. Anyway. And if you, if you'd build your system in that way, then you're also losing out a lot on the actual capabilities of the specialized thing that you actually selected in the first place, right? You select the graph database because you want to make use of the nature of the store. It's a Architectural decision.

39:25 Exactly. Yeah and it's not something, I mean you could change, you could argue that you would want to exchange one graph database. Another one, relational database for another. But if that's the, if activities like these are, or if these are the main tasks, you have to perform on a day-to-day basis, you're not probably going to earn any money, right? So yeah, that's not that's not the different business value. We optimize for having it about their own, being able to ship features, right? That's that's kind of the thing. So, I want to shift to microservices in monoliths, but I think there's any connection here, because, on Twitter, or last, I don't know. A few weeks there's been again, the monolith versus microservices thing has come up, and it seems to be an ongoing debate, but I'm curious on is from your perspective.

40:18 How does domain-driven design impact, the architectural decisions around For versus micro Services is there, is there a valuable connection here, are they to kind of separate things to think about, mmm? I mean, there are a couple of things in, in domain, driven design, couple of Concepts that guide the, the potencial separation of logical system into different logical Parts, like bound contexts on top. As we discussed already, they are. There's a tip of a module, that's kind of a subdivision of a bounded context. So each part of context can consist of different logical modules that he'll just help you to define something that's hidden inside and something that's exposed to other modules.

41:08 And then you can get to these kind of cohesive elements. There's domain-driven design, does not like form an opinion on what to map those to those logical Concepts to. Whether a bounded context is supposed to be a sister, a separate process, it could be a build module, it could be whatever, module could be a Java package or something. If we're sticking to Java that the that's that's based that's exactly or that's actually architectural work right to decide like what physical abstractions if you if we can talk about yeah physics in in software or physical physical world. But on each of these like levels processes build modules, let's say something smaller, like packages, you just you have live on with with different trade-offs of what you can on cannot do anymore.

42:07 And first example this let's say that you're designing a system and you've got inventory and order. I think that's a good system and you you design it where that is all within a bounded context and Then in your implementation, you end up having in the same relational database tables, that represent both of those things. And in some pieces, your application you do database join across those two tables that breaking those two things out into separate. Microservices becomes really challenging and I think that maybe owner production. Yeah, part of the value of domain driven design in this is that it tells you, You where you can split things out. Because you've bounded the context and you've said, okay, these two things are intertwined, we're doing a database, join on these things, on the actual implementation side and so do not try to break your bounded context apart. That would be a bad place to try to do my Wells and from a management context.

43:13 It also would help you decide maybe teams working on things. Like if you had a remote team in a different time zone working on a different, Section you'd want maybe that would be your you know your API interface that you want to end those people would just you know they would focus on that thing anyway. Let ya know. Sure it's this. I guess that's the two primary drivers behind like physical separation. One is and that's the bigger one. Even I think is organizational boundaries, right? Team, which kind of means team structures and Also deployment Cycles. Basically, from more from an organizational point of view rather than from a technical deployment point of view, the other one is scaling usually, right?

44:06 If you have, let's say in that e-commerce system. If you see that the catalog, but just the browse browsing the catalog is like under heavy load, then you might want to consider to have a separate system for that, so that you can basically cover the retail out. There there's other options. That as well. You could try Cassius for these particular URI. So what have you? It's not necessarily or it's not a necessary thing to to separate that part out if you see that problem. But the organizational Arrangement usually is a big driver for that physical separation, everything else. And we actually see kind of a bit of a trend back to that is, is something or we see the trend to people building what we call module lithic software these days rights are genetic.

44:58 Yeah. It's kind of like, okay, you build something in a in a, that's a single process. That's still has some internal structure and that that applies. Actually, some means that you would have to apply if you separated it out, but you wouldn't usually don't if you basically keep it contained because it's also means a bit like Hang up on some convenience stuff like you mentioned, James the that stuff like interconnected database tables, right? You could you could go ahead and still cleanly separate like the data of your let's say or the module and the order at the data of your inventory module and make sure that you, let's say just have a store.

45:44 Let's say the order IDs, or product IDs or what have you? But without a foreign key relationships, but you still get the, get the connection. But if If you at some point decide to actually, to pull out that part of the system, then you are already prepared and you have your data layer basically prepared that basically, that continues into the the way that these individual logical modules interact with each other. Whether it's like direct method calls or whether it's like an event that's published on one side of the system and then listened to by the other that Would not necessarily have to be that case or it have to be that way in a day in a monolithic Arrangement but we already do. So because we want to basically establish these logical boundaries within our system or monolithic system because it makes the system easier to test or parts of that easier to test. It's basically to what I'm guessing is bounded context idea.

46:53 Help us to decide what pieces potentially could be split off and for team reasons, or runtime performance reasons or whatever it may be. But is there a connection there? I mean, you could, you could plate. That's a, a very or reasonable. I'm not saying default mapping, but you could argue, okay, whatever. What forms about context, we build as a as a separate system because we align the team around it. And that's Of like everything order or everything inventory as we as we just already discussed, but that Bounty context might have like an internal structure that we then represent as individual modules. And then we have again like mapping step on to either build modules or as we have in this in this new spring project here, the spring module is stuff.

47:44 We use packages quite a lot, right? We basically say that there's a Java package that forms the entry point into a module and we give you a a few guardrails or means to actually make sure that this modular structure that you've created by just arranging your code in a certain way is you retain that and you're not accidentally introducing like I like, yeah, I wanna hear more about this because I think I saw a little bit and it seemed really interesting but this is the idea that you're building a spring project and you're architecting an organizing it in a way that is able to be modularized. Later. And and you it doesn't impact you as the developer. Like you're not having to the developer experience around creating something that's modular and packaged is nice versus the traditional way was that?

48:42 Oh man like now you got to think about you know, how you're going to share your interfaces in the contract and how you do contract testing and all this kind of stuff. Does that mean? So the the idea of the project is that you You can build a spring boot application. That's other what it's based on and that you get the as a developer, you get the ability to express these logical Parts, you would use Java packages as to do that on a let's say the most high level what you get with. It is means to in from this, from these packages, is to expose, certain apis, like in the spring beans, which is like object instances at runtime that you can invoke or events. That Basically are published through the spring event bus within the jvm so it's not not kind of no messaging at all involved yet, alright? This point at least you get that and what you get around, this is both an arc unit based API to verify that you have a non cyclic structure.

49:44 And if you want to and express like let's say this, module is allowed to only depend on that other. You would be able to do that as well. But as we've seen a simple noncyclic Arrangement, already gives you kind of 80% of the of the kind of structural degradation prevention basically. Yeah, you get the verification and what you also get is the ability to bootstrap individual modules within that system in a test so that you can just say. OK, I want to only run the order module, for example, and it would then basically just limit the Execution to, to those beans and and what have you. So it's a very very non-invasive way for developers to get just structure your applications non-invasive because everything that's complicated usually puts people off.

50:40 If you want to do, we want to be be able to do the right thing in a very easy way, to the like, osgi, but actually like usable and friendly in this. There's been a lot of discussion and is this still Questions that come up with. Like, also around JP + S + OG is also another thing, but if you look at those, especially J pm has been built to modularize the jdk, it's very security focused, and you need to the libraries to, to play to play into this, right? They have to provide this, none of it. None of this is usually the at the concern of the developers in the first place. If you again, you have your domain. What the system needs not work. It's not with the For needs. I want, I want to structure my application following the domain and I don't necessarily want each module of that to be a separate jar file, which is what JP mess would require. Um, so it's yeah, it's just here's my boot app. I just lay out the logical Parts, the business driven Parts in a certain way.

51:42 And that's all I care about for now, right? And it kind of leaves the way a lot of the complexity, it by also not being and like, as As deep or it's not like that as deeply ingrained of course in military service in the jvm, but it does the trick. So there's a bigger bang for the buck kind of ratio here and it's, it's kind of that project is basically a technical implementation of stuff that we have conveyed through, like presentations, or in consulting's, oh, go ahead structure, your application like this, put your configuration code in. Do it like this? It all these recommendations that we verbally verbally given our kind of now embedded or in implement the name of the project.

52:32 Again. Spring module is basically spring module with its modulus. Yeah, we want to help help you build, module istic, application applications. And that doesn't mean, I mean that there's always this discussion about modulus being so close to monolith. Do we tell you to build a single application? No, we don't. It's just a means to to whatever system you built, whatever Arrangement that is part of, it is likely to have some internal structure and we want to help you to express that internal structure. And then give you guidance around tests, there's observability features in there. Because in the microservices arrangement, you usually put something like Zipkin between the systems to be able to track the, the flow, through the, through the, through the individual systems.

53:22 Why shouldn't you have Something available in your module, lithic application, right? So that you can track that the order module invokes, the inventory or would have you track the number of events that get published all this, this this kind of stuff. That's, that's kind of exposed to any any runtime platform. Then micro Services versus monolith. The answer is yes, both and it's called module. It's so also there's this quote from Stephen Covey said, we like monolith so much that we would want to build many of them. And that's kind of that's kind of the spirit, right? So it's not about like one system or a thousand systems, it's like, okay, you align the number of systems with your organizational structure and you still have means to organize within those systems, because like in the Des public discussion, it's usually like this, there's this system and if it's a micro Then that's the level of granularity and there's nothing in there.

54:28 It's like just this one thing which is usually not the case, right? It's there. You can rather build it slightly bigger thing that has internal structure. So Embrace Conway's law. Don't fight it. Yes, I do. Yeah, it's sort of seems like I would kind of sum this up by saying that domain driven design. Well, we make these decisions when we're programming. And because of our training and our orientation, we make them purely for technical reasons for within our own little world. What domain driven design does is it says, Ah, I can give you information to help you make better decisions to produce better results to produce more maintainable, understandable, Etc, results. That seems like the kind of what we're going for here. Sounds like a value proposition of domain-driven design. It's almost like a system of thinking it is and giving you a lens to see things through that should help you deliver Better Business outcomes for what you build. But my question that I kind of pitched it you at the beginning, was why, why is it big now when it's been 20 years since the book got written.

55:50 What's a Jane? I mean, there definitely is a renascence of the I mean, I've been Starstruck by the book like from the from the very beginning and that led to Spring data repositories and what have you? But I think that that microservices discussion, like the hype that kind of leaf is seen like, five years ago at the peak with Netflix, thousands of systems. And what have you that kind of got people rethinking about, like, where do we put boundaries, right? And like, do we want to have like two levels of abstraction or do we want to have multiple ones and which which quality goals? Do we align with which level of abstraction write this kind of organizational stuff at the bound context level and in this boiling down and how much Freedom do we want or do we need in terms of like the choice of Technology?

56:38 Like, do we want to use different programming languages? And if we want to do, so we have to do processes. All these discussions have started with it with the, with the microservices movement. And it's, I think it's an important piece also is that Microsoft Services is the has been the first architectural style, new architectural style post the agile software development kind of development. So it's so it's breathing that that kind of that kind of idea or that energy because you would want to align your microservices with your business capabilities, right? It's kind of they seem to have the same roots to some degree, all these these, these movements. And one being the organizational or Side of things and the other one. Being the technical implementation idea. But waterfall was, much more aligned with monoliths conception.

57:33 Yeah. Sure. Because in my user have a project and you build one system to satisfy one project, right? This is kind. Yeah, been that idea and all this kind of like centered around like different teams doing different things. In the aligning, the software structures with that has definitely. Like or there's there's some connection there and And I think that especially the Strategic design part of DD, that we kind of, like, just briefly touched on today, kind of connects to that, right? And then that's kind of, oh, there's this book, and let's see what ideas were in there, and then people are coming back to kind of realizing that it's not necessarily about the technical implementation of microservices, but rather about like, modularity and different different scopes of modularity, at different levels of abstraction that Our and like, and the interface between that and the, and the actual structure of the organization. Yeah.

58:30 Sure. And yeah, it did, especially the Blue Book making exactly that connection. I mean, the partners paper is from what 79 or something. So it's not particularly well, it's written in the book is kind of a, like a lady. You mentioned the part of this paper, put modularity paper. Huh. After it down? Yes. No. I mean I know that. It's the I think the, if anything modularity, related, it's less exciting. This paper. It's a bit like the Conway's law thing. The Conway's law paper but it's II. We can look that up for the show notes and oh, yeah, sounds great. So do you have any questions that you want to ask us and you don't have to it's just anything we missed. Yeah, or anything?

59:18 We missed. I'll make maybe maybe also like for the, for the audience. Because that's probably like people on the Discord at that are like this into the episode later. I mean, the thing that I'm currently like, most interested in is like, what strategies two teams, apply to when they have to make all these decisions that we've discussed right when they and they planted a new piece of software and what are their their drivers behind a decision to like build a separate system or not, right? What is that? Think through that. And yeah, and do, do they have architecture team or something that they can go to and discuss that with or they being told by an architecture Team, how to do it and I'm sure there's a huge variety of set up there is this gap between like when you do like things like event storming, right?

1:00:16 And you have that that wall of Post-its and then you kind of have to somehow translate that into you get back to your computer. It is some open up your IDE. So there is a as I usually say, posted stoned running production, unfortunately, except you work from my road, and then they do. But there was an attempt once to run. You are male models and make that your prediction for a long time, and they always go. The last time I heard it was uml never going. Yeah, we're 90% there. We just have to do the last 10% and then never heard from him again. Yeah, is I think Chris Richardson, you probably. Yeah. He recently polled, I have to look it up. He recently posted some he's formalized this into some kind of process where you basically, you finished your domain analysis stuff.

1:01:14 And then how do you get to the decision of what to build as a separate service. And what time does modules within? That separates of I can, we can definitely look that up. Yeah I don't find it right now but yeah yeah I'm sure it's up on his decision. Making in general is fascinating a something. I don't know. I have to I have to look this up later. Okay. I'll go find it. Yeah. Anything else we missed? What's been pretty extensive discussion? I think. So yeah. Very educational for me so yeah. Yeah, already get some feedback on the Discord Channel. Yes. Yes. Join I guess we don't often talk about the disk. Cord Channel and we should mention it. That we do have a Discord channel. It's always in the description of the podcast and if you want to discuss these things more, join us there.

1:02:03 Yeah, thanks Ali. Thanks Bruce. Thanks James for having me. Cord Channel and we should mention it. That we do have a Discord channel. It's always in the description of the podcast and if you want to discuss these things more, join us there. Yeah, thanks Ali. Thanks Bruce. Thanks James for having me.