Domain Modelling - Yves Reynhout - DDD Europe 2019

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hi everybody Cindy Tommy free notes and software consultants and I mainly work together with companies that tend to build products not projects and today I wanted to talk about two main modeling and there's already a spelling mistake on there I think because it's modeling written with one hour with two L's I think it's a difference between English from Britain and American English so what is domain modeling well domain modeling is it's basically a bit of an art form it's not something that you can basically say that that is a science of sorts it's not that when I'm on a project for example that it's been a systematic approach to this and what you're trying to do is is you're trying to find concepts abstractions that fit the domain you're in and then actually capture a lot of knowledge and language in doing so but it's very much an act it's something you do it's not static it's something you do continuously and when you find these concepts you kind of put them together in such a way that you're able to solve one or more problems that are present in that particular domain now it's not a lot about what I would talk about in in these 30 minutes that we have and you could talk about all the models that I've created and built but then 30 minutes would not be enough I'm afraid and so I thought well maybe I should try it with an example of what that the main modeling is actually like and I thought well what could I use that's fairly simple to grasp that everybody should know and I thought well I have an item in my possession and maybe some of you have this item as well it's called a wallet so if I ask for a raise of hands who has a wallet Wow so we're definitely not disconnected here and so if I want to model my wallet basically yeah there's our first question that pops up in my mind is what makes this my wallet how would you know this is my wallet have you ever been in a shop or in a on the street and you found the wallet on the ground the first thing you do is you pick it up basically and look around like John Travolta basically where and then you kind of say well nobody's reacting here so you open the wallet and you go looking for clues and in my wallet there's my identity card and somewhere hidden away I'm sure it's here sorry oh there's my driver's license but a very ugly picture I'm not going to show you but there's my name on him so that kind of hints at this being my wallet and the kind of way I could come up with a very concrete model of that would be this so if there is an identity card on there with Eve's name on it or a driver's license and I find these things in his wallet it must mean that that is his wallet but what are an identity card in the driver's license so a lot of what we do in the main modeling is finding abstractions right and so the abstraction that I found was well an identity card or a a driver's license that actually is sort of a proof of identity and then that refers to a person and I found it in a wallet so this helps me solve basically I would imagine 90% of the scenarios if I'd asked somebody basically for his wallet I could solve finding out who their wallet belongs to using this particular model that I've come up with this is the only way I could have modelled it no if you if you want to be really precise maybe I should show you a receipt that I paid for this bullet and there's a serial number on there and the serial number is in my wallet but Allah when domain modeling allowed boils down to yeah how far should I go how much should I abstract and sometimes you come up with or maybe this is good enough because I'm able to satisfy a lot of scenarios that I have so let's look at it my wallet in a bit of a different way and I do mean this is a unique experience I'm not in the habit of showing people the contents of my wallet it's a once in a lifetime and you can actually say after this conference you've seen the inside of my wallet so I have here a $5 note I have a five British pounds I have so here's it where we find out how rich I am oh there's like fifty euros in here there's some coupon that has expired in here there's a receipt in there well which I passed student tunnel there's a lot of debit cards in here credit card there's a 1000 is in here oh there's loyalty cards there's business cards there's coins in here oh this is for and then there's the card of the hotel so there's a lot of stuff in my wallet I mean I sanitize it before I came here but already it has accrued a lot more stuff basically since I'm here so again I can somehow model is where I come up with oh so these are all the things that are in in my wallet and a lot of times when we do the main modeling we kind of take out the unnecessary things and we abstract so I'm not really interested in all these bonus cards and coupons and things like that but I might be was there for the problem that I'm solving and granted I've been the domain expert here I'm more interested in the money and the cards and the proof of identity if anything else so that when you do domain modeling is that you actually choose what goes into the model it's not because the real world has all these aspects that you need to model them in your I'll need to bring them into your model and far often more often than not basically this is where we end up this is where people stop and then they show a big diagram with all the entities that people found and they can I mean the tooling is there to generate your databases to generate your classes etc but that's ultimately where most people stop and that's also where were I for a long time stopped but then I started to wonder well there must be more right and when I discovered the main reason domain driven design I found out that if focuses a lot more on behavior as well so if I look at my wallet basically what behavior does my wallet have what function does it perform that's fairly simple right you put money in and you take money out you insert or return a card or you use a card at that point but what's interesting is that the conversation I'm now having becomes much more interesting where is the money coming from where's the money going to how much money which cards do I put in there so I can start asking a lot more questions about this obviously yeah that's not the end of it because what makes it much more interesting basically is that we start looking at the rules and what rules could govern my my wallet well a few weeks ago I was in a bar and I ordered one of them fine Belgian beers and I drank it and I opened my wallet and it appeared there was no money anymore in my wallet now luckily I had my credit card and I could pay that way or I could run to an ATM basically and get money that way but there's an actual constraint in here if I've taken out all the money basically I cannot take out more money that's an actual physical constraint that's a rule that's tied to my wallet and that could manifest itself in a piece of code and even if you don't know how to read this code I mean you can clearly see that in order to take money out I'm basically checking whether the amount available in my wallet is bigger than the amount to take I've converted there the thing here but if there's not enough money basically in there then I'm just gonna say well there's no there is there's insufficient money in my wallet and again that makes the conversation a little bit more interesting and our model starts to I would say grow in knowledge that it's capturing of what's happening in the domain even though my wallet is a really trivial domain if you think about it I hope until now we've been looking at my wallet in a particular context which is just my wallet but when you're solving problems you're you're always in a particular context and what I mean by that is that you work for a specific company you work with a specific set of people so the circumstances in which you are doing this domain modeling activity are going to dictate a lot and you're trying to solve a particular problem now imagine that I'm a game designer and I come up with the great idea to actually create an in-game currency that people can spend so how am I going to present that to to the people that are using my game well I may come up with the concept of a wallet again and the behavior I'm looking for there is that I'm putting in V box and I'm taking out V books where V box is the currency in mine in my game anybody know which game this is yes exactly fortnight but in designing basically the wallet for the game something happened we've adopted the language our own language of the currency that we're employing but there's no concept of a debit or a credit card in there so a lot more happens when the main modeling is that you're ditching the abstractions that you found useful somewhere else and you're not trying to reuse that basically in in some other context now here it's easy to see that my physical wall basically I mean could you could be useful as a basis for for this type of wallet but sometimes like the game is more interested for example in what type of transactions have happened and all of a sudden my wallet starts to look a lot more like my bank account now is there a way in which I could mimic basically all the transaction that happened sure whenever I pay for something I should get the receipt whenever I get money out of an ATM I should get a receipt put all those receipts in my wallet and I basically have a similar thing so there's a lot of analogy that we can reuse basically when we're designing in certain domains another example a casino this is an online casino and again our wallet starts to take shape here where we can actually deposit money and or cash out basically we can place about we can win about and there's a different type of currency here which is bonus money which is time limited and there's no is there how would I say this is there an analogy that we can find in in this wallet that represents bonus money sorry a gift card a coupon anything like that basically is a analogy that that we can find there but I want to point out something different here I mean the ultimate thing that we're doing here is that we can simplify things it doesn't matter what we win money or cash or cash out it's basically again putting money into the wall and taking money out of the wallet so whenever I mean if we compare it to this whenever you have a a lot of language around it around a certain piece of our model in this case the wallet we should think while carrying out simplify this right and that's a lot what goes on in the main modeling is that you try to find something simpler that would work just as well but sometimes I mean your preconception of a wallet just does not translate that could be an entirely different way I could be looking at my wallet what if I am working for the manufacturer of this wallet how would I be looking at this wallet I'd be looking at oh this is a leather wallet and there's blue things on the side here there's fabric on the inside being used their stitches being used so that means thread so if I have to come up basically with a model in that way then it would be entirely different and this central concept of a wallet basically no longer be present it would be more like there's a product group which is the wallets because they'll probably have more than this type of wallet or this model of wallets basically if you will and I'd be much more focused on the bill of material and how much leather I need and how much fabric I'd need and the assembly instruction that go with that so to summarize effective domain modeling means that you need to have access to domain expertise this is probably the most essential thing that I find that people struggle with is that they come up to me and they say well how can I do DDD and and I say well who's your domain expert do you have anybody you can talk to and find out more about the domain and there's obviously doing a lot of analysis in design I mean the whole thing we've been doing in here is essential to domain modeling it's this act of exploring and looking at things in fine-grain detail if you will to find out more how often do you find yourself doing that in the domain you're in have you sat next to an end-user or domain expert while he's doing his job and it's also about asking a lot of important questions and interviewing people to find out more and okay we can do a lot of brainstorming experimenting along the way I mean isn't just not finding the one model it's finding maybe three or four models and then choosing which one actually fits the problem that we're trying to solve better there's also the fact that when you're creating a model which is kind of an abstract something it's not a visual it's not a piece of code but at the end of the day we want to bind basically that model to that piece of code such that we feel comfortable that the model and the implementation actually match and as I've demonstrated here I've used a lot of language that goes around with my wallet so even though this is not probably the deepest type of model that one can have I do hope you found that in a short amount of time you can find out a lot about a specific domain and it can entertain a lot of ideas about how to actually represent that using abstract notions and that's it thank you [Applause]
Info
Channel: Domain-Driven Design Europe
Views: 2,037
Rating: 4.7894735 out of 5
Keywords: ddd, dddeurope, domain-driven design, architecture, software, modelling, microservices, messaging, software architecture, software design, design patterns, sociotechnical, ddd europe, dddeu
Id: tjiuDQbkRFY
Channel Id: undefined
Length: 19min 14sec (1154 seconds)
Published: Sat Dec 21 2019
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.