Domain Modeling for Humans and AI

Diagramming Domain Expert Models

Domain Modeling for Humans and AI

Lesson Description

The "Diagramming Domain Expert Models" Lesson is part of the full, Domain Modeling for Humans and AI course featured in this preview video. Here's what you'd learn in this lesson:

Mike explains how to model plant stages and durations as a value object, using clear names like "plant stage." He focuses on essential seed packet data like time durations and start dates to keep the model user-friendly and relevant.

Preview
Close

Transcript from the "Diagramming Domain Expert Models" Lesson

[00:00:00]
>> Speaker 1: Do we need, like, a value object that represents or that can contain information about a given stage and a duration of time?
>> Mike North: Cool. Okay, tell me more.
>> Speaker 1: Well, if you know, you could represent the indoor growing time and the hardening time with the same value object, those two entities can be, or maybe could be discrete things per plant.

[00:00:24]
Unless hardening is, like, all with seven days for every single plant, you can use the same sort of value object to represent.
>> Mike North: Great. Okay. And I'm not a gardener anymore, so using the word value object here is fine. But, like, what would we call this thing? Like, how do we give this a name that makes sense to our gardener?

[00:00:45]
>> Speaker 3: The plant's name?
>> Mike North: This is the class. This is the class. I think what you're trying to capture here is there's some. Something here, right. Like, I've drawn little boxes here. That's a signal, Right. If your gardener gets up and they say, like, this is a thing, and they circle a thing and they say, here's what I'm describing here.

[00:01:07]
Like, that's teasing that up.
>> Speaker 1: Planting stage or something like this.
>> Mike North: Yeah, like plant stage. Yeah, we could call it that until we come up with a better name. But those are words like, you know.
>> Speaker 5: Do we need to know more? Are there more stages than really just the.

[00:01:28]
Like, would you call it the germination stage where it's inside?
>> Mike North: Yeah, there could be. Let's start with this, though. I mean, realistically, there are. There's like you plant the seed and then it's in the hydroponic thing. And then you put it in a red party cup. Cause it's too big for the hydroponics.

[00:01:47]
Like, it goes deeper. But I think we have enough here. We've got a plant stage, and then we've got a time period on it probably. Right?
>> Speaker 1: Yeah.
>> Mike North: How should we represent that? What is the time period?
>> Speaker 5: Days are probably the easiest.
>> Mike North: Cool. And describe to me in words, like, what's an example of a time period?

[00:02:22]
>> Speaker 4: Is it like a range of days?
>> Mike North: It could be a range of days. Like specific dates, like March 27 through April 9.
>> Speaker 3: So a start date and a length.
>> Mike North: I think it's a start date and a length. Right, right. Like, this is a duration.

[00:02:45]
It's a time duration. It might already have duration in there somewhere. But, like, let's say and it's a value and a unit days or whatever. Okay, great. And so this is a time duration. So now we can model a plant stage. We could say, all right, here's the germination time.

[00:03:17]
Here's when you're planting things now what do we need on this? Great. We can model durations, maybe give it a name. Okay, so great. You could say, here's some kind of tomato, and there's like a germination duration that's this many days, and then a hardening duration that's this many days, and then replant it in the ground, presumably, then it's growing and then it fruits, and then I can harvest.

[00:03:53]
So it's that many days, and then it's continuing to fruit until it gets cold and gets knocked out. This is great. Let's pop back up to seed packet, though.
>> Speaker 4: You need a start date in there somewhere, don't you?
>> Mike North: Mm. Interesting. On seed packet.
>> Speaker 1: On the plant stage.

[00:04:09]
Plant stage has the start date and the duration from that start date.
>> Mike North: I'm so glad you brought this up. So this is where, like, we're talking about the seed packet here. I'm not. There's also gonna be a concept of a plant, like, you put a seed in and the plants growing, and that has.

[00:04:30]
There's some state there, right? Like there are 200 seeds in the tomato seed packet, and those can become each an individual plant. But we're trying to model the packet here. Does that make.
>> Speaker 4: Does the difference make sense, Mr. Gardener? Does every plant have a indoor planting, a hardening, and a plant in the ground phase?

[00:04:52]
>> Speaker 5: Well, the start date would depend on the location.
>> Speaker 4: Start date is very. All of those things. Plant stage and time duration are very much derived state from the seed packet. They're not their own entities. You're going to pick the date, the germination time, all the information in the seed packet, and create those things as value objects based upon that data.

[00:05:11]
We're not going to store that. If everything has those three stages, and if we have the data to determine what stages they have.
>> Mike North: This is great. This is great. A very productive conversation here. Seed packet is almost like the template for a plant, if you want to think about it that way.

[00:05:36]
When we say we have a time duration for germination, that's like. That is sprouts in seven to 14 days. That's what we're trying to capture here. Now, once it's planted, there's a time where it's planted, and there might be a specific, like a date time, a date and a time where, like, we've entered the beginning of that range, we've left that range, and that's gonna be a different concept that we're gonna model.

[00:06:04]
But, like, these seeds sprout in seven to 14 days the first year, midway through the Year, the next year it's still seven to 14 days. Right. It's sort of. Does that difference make sense? All right, let's jump back into this though. What else do we need to know?

[00:06:21]
So I like this. We have plant stage and there's kind of a many relationship there. Actually it's at least. Sorry, I keep picking the wrong one. It's one or many plant stages and then each of these has a time duration. What else goes on the seed packet? Quantity.

[00:06:43]
Let's start there. That's a number.
>> Speaker 3: Variety.
>> Mike North: Great.
>> Speaker 4: Plant family.
>> Mike North: I like that word better. Plant family.
>> Speaker 4: You mean a name then, right?
>> Mike North: Name. Great. So let's use our tip of going through a concrete example here. So That's a name. 200 C's in a packet.

[00:07:33]
Tomato. And then some date. Some date. That's appropriate. That's one I would probably choose not to model because expire date is what matters to me. Maybe seeds have different shelf lives. And really what I care about is there was this story of, we didn't document it. I want to plant seeds before they expire.

[00:08:05]
But like purchase date, I would argue there we're getting a little bit close to that trap of just like modeling more than is necessary on the seed packet in order to solve this problem. Now if I were accounting for my seed purchases and I wanted to like deduct them from taxes or something, absolutely that matters.

[00:08:25]
But that wasn't part of the pain there.
>> Speaker 4: You bought a whole bunch of seeds last year at a discount that were almost expired, so it doesn't really matter.
>> Mike North: There you go. Yeah. Yep. Yeah. Or I could have bought them from a friend. Yeah, like, exactly. They're about to expire and so the purchase date is unknown to me.

[00:08:43]
But I do know like, I do look on this real seed packet and they have a sell, sell by. And like here you can see evidence of that. Remember I said it's like a year based expiration kind of thing packed for 2024. There's a clue right there. It's packed.

[00:09:04]
These are made for a season and it's less like, look, 12 31-34. Like really, does it expire on New Year's at 11:59? Like it's really about sort of the seasonal rollover there. So this is why looking at concrete examples often yields some great insight here. It would have been totally easy for us to overdo the expiration date and been like, let's filter by expiration date and let's let you put in a day, month, year.

[00:09:35]
But really, if we were building this feature, you just have a dropdown with years, and it would be fine. That's probably as complicated as it needs to get. Okay, let's shift into taking some of what we've learned and implementing it.

Learn Straight from the Experts Who Shape the Modern Web

  • In-depth Courses
  • Industry Leading Experts
  • Learning Paths
  • Live Interactive Workshops
Get Unlimited Access Now