
Lesson Description
The "Contexts Diagramming Exercise" 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 introduces a domain modeling exercise for a gardening app, focusing on raised beds, plant layouts, and spacing. He defines key entities like gardens, beds, and plants, stressing the need to capture essential elements like positioning and relationships. He also covers seed packets, plant metadata, and future ideas like plant cooperation.
Transcript from the "Contexts Diagramming Exercise" Lesson
[00:00:00]
>> Mike North: Now let's dig into another domain modeling exercise. We have this concept of a garden and we have this concept of raised beds. Just remember that photo I showed where it's like those metal things filled with dirt plants in them. I have some statements here. These are user testimonials.
[00:00:20]
These are things, pieces of pain or elements of pain that a user has to deal with. Or they reflect something they wish to do that is difficult for them to do today. I made these intentionally vague and I have used maybe some terms like square foot, garden. I'm not sure everybody who's taking this course understands exactly what that means.
[00:00:47]
Perhaps some of you in the room don't understand what that means. This is a cue for you to tease out more, ask questions, see if this needs to be part of the common language we use in this gardening domain model. So your task, let's do the domain meddling exercise around this app.
[00:01:14]
Sorry, I mean, we kind of already know like a little bit about where we're going. Oops, sorry, I keep going back to the other one. We kinda know that we're going here. But actually, better still, let me take you back to this. I'm trying to get organized around these things and so let's see if we can have a conversation.
[00:01:38]
How do we represent this in software? What's at the essence of this? The things that we need to capture. And let's start with the things that we feel are necessary for any valid solution to this problem. And to be clear, like, we're departing from seed packets now and we're focusing on the layout of plants in a garden that is mostly focused around raised beds.
[00:02:11]
So I'm gonna start us off.
>> Mike North: Clearly we're gonna have a garden. That's the easy part. This is for sure an entity, like a garden has an id. Maybe I have many gardens. Maybe this turns into a garden organization as a service app where neighborhoods can rally around this.
[00:02:40]
How can we try to represent in entities, value, objects, relationships, constraints.
>> Student 1: Raised beds inside that?
>> Mike North: Raised beds.
>> Student 1: Each raised bed have plants.
>> Mike North: Yep, what do you mean by plant?
>> Student 1: Array of plant.
>> Mike North: So clear, like we'll need a plant. What does a plant mean?
[00:03:17]
>> Student 1: You're dropping a seed and then you can add multiple seeds in a raised bed. And then-
>> Mike North: So this is like one plant planted in the ground at a particular time. Great. Not the abstract concept of like, there exists this concept of a blueberry plant. And I can sell you many of these things, but this is like I've handed you one, right?
[00:03:40]
>> Student 2: What about a planting area for the raised bed?
>> Mike North: Is that, sorry, a new concept or renaming this concept?
>> Student 2: That would be a new concept of value entity. The raised bed has.
>> Mike North: A planting area, okay. A value object or entity. Tell me about the difference between planting area and raised bed.
[00:04:05]
>> Student 2: I mean, I guess the width and height could just be with height and depth could just be properties of the raised bed. Unless you're planting things in the garden outside of a raised bed. And then a planning area could apply to anything that isn't a raised bed in addition to describing the areas contained within them.
[00:04:28]
>> Mike North: Now we're thinking critically about this problem space. So I'm going to say I actually call those things on the ground. I call them beds. I have some raised beds, but I also have these little beds on the ground. It's sort of a space that plants go into.
[00:04:48]
So maybe the fact that it's raised doesn't need to be modeled. Now this really makes things interesting. Depth. Like what is the depth of a bed on the ground? Well, is it the radius of the planet Earth? Like what are we talking about here? So I love this and because I actually intend to use this app and like at the end of this I wanna show you some tickets that I've prepared if people want as like a final project to do something interesting in the context of this app.
[00:05:23]
But like depth starts to become really interesting if you're planning something like bulbs where you can have different layers, you have ones that can be planted deep and then ones that can be 6 inches above and they'll sort of all pop up at different times. This is like a lasagna of bulbs.
[00:05:39]
If you want to think about it that way, let's stick with width and height. Right now I notice it's a top down view as far as we're concerned right now. And we're not trying to get into depth quite yet. But a real solution, a robust one, would certainly model it that way.
[00:06:02]
Without making final decisions here of any kind, what other things do we want to incorporate? So garden clearly has many raised beds.
>> Student 3: I guess location could be on the garden. There might be some sort of like X and Y situation for the beds within the garden. I don't know if that's important to this.
[00:06:28]
>> Mike North: Yeah, well, absolutely right. Like thinking back to the first exercise we did, like, if I want to answer some of these questions around, like when is the right time to plant these things? Location is absolutely critical. I'm going to bend your X and Y point here. I'd argue at the very least we need to know on plant, like in the context of a bed, where is it?
[00:06:59]
And we're going to need a position here. We happen to have already a value object called XY coordinate which will give us a good indication there.
>> Student 4: So does a planting area have a position within a bed? In which case would you want to tie the plant to the planting area and position?
[00:07:20]
>> Mike North: Yeah, so stepping into my subject matter expert role here, I'm going to say I can't really tell the difference between these two things. Like to me a bed is a way to describe a planting area.
>> Student 4: Is the planting area not one of the tiles within a bed we can drag it into?
[00:07:40]
>> Mike North: That's a good question. Let's forget that we have seen a peek at a solution there. But if you were to ask me that same question in the context of like how I think about a garden. Well, I have my garden. It's like the big photo I showed you and then I've got beds, some of which are on the ground, some of which are in those metal containers and then plants are positioned within those beds.
[00:08:07]
And like, while it's true that each of those beds has a position within my garden, really what I'm trying to. The problems I'm trying to solve here have to do with like tracking how much sun each bed gets. Or am I planting things too close together or, or am I needlessly planting things too far apart and I'm wasting space.
[00:08:30]
And if you just show me like some list of little bed diagrams, like a lot of my needs are met and I don't need it to be. I don't need to be at a two scale, real diagram of my garden. Although that would be very cool. I'd say we're going well beyond the basics.
[00:08:49]
If we go all the way there.
>> Student 5: Would we have any plants that exist outside of a bed? Seedlings or.
>> Mike North: Yeah, great question. I think I can simplify that by saying whatever plant exists in. I'm going to call that a bed. If it's one of those hydroponic things, that's a bed too.
[00:09:12]
If it's in a red party cup, maybe that's a bed of width one and height one. And I'm just going to call that a bed. It's a good starting point. I think maybe what we can get out of that is plant always, always has a pointer to a bed.
[00:09:34]
Beds can only exist within the context of a garden. So what I'm going to do is I'm going to combine these because your subject matter expert says I'm Confused here.
>> Student 3: The plant would have a size.
>> Mike North: Okay, say more like how big it gets.
>> Student 3: How big it gets
[00:09:57]
>> Mike North: How big it gets. Maximum,
>> Student 5: How many positions.
>> Student 3: When the-
>> Student 5: The planting distance.
>> Mike North: The planting distance, right?
>> Student 3: Yeah.
>> Student 5: Now wouldn't the plant just have kind of plant metadata, which is all of the stuff that the plant.
>> Mike North: We're gonna see? It turns out we're going to use the same plant metadata concept, I'd say.
[00:10:17]
Yeah, absolutely. It has a planting distance for sure. And, you know, I'm going to tell you, I only care about feet here because I mentioned I want to embrace the concept of a square foot garden. So really, like in reality, when we say there's this plant distance, it's a circle.
[00:10:43]
It kind of represents like, how big the plant's going to get, how competitive it is for nutrients with the things around it. But gosh, a real simple way to draw this out is squares. And so we're gonna approximate it. Square foot garden is a term people use where you can allocate a square foot and sometimes that means you can plant nine carrots in there in a three by three grid.
[00:11:17]
Or if it's a tomato, it's like a two foot by two foot square in your garden. It takes up all four of those spots. And that's sort of like the crude way of getting it pretty much right. And a lot of people do it this way. All right, plant has a position, it has a planting distance.
[00:11:38]
I'm actually going to do this. Come on. You're not going to let me scroll. I'm going to say a plant comes from a seed packet. Ultimately it comes from a seed packet. And I, I think we already put planting distance on here. I'm going to refine. I'm going to refine our domain model here.
[00:12:16]
We've made a change. We actually added this already and we can just refer to the seed packet as the source of truth. For that's sort of our, like, it's our plant factory. Right. It's the template for a plant. And we don't need that data to be stored on every single plant that's in the ground.
[00:12:44]
Like, If I plant 40 snow pea vines, I can point to the same.
>> Student 2: Seed packet maybe outside the scope of the exercise, but like, with. I don't know a lot about gardening, but I have heard the concept of like permaculture, right, where certain plants planted near each other can be more cooperative and effective and grow better.
[00:13:03]
You as a master gardener with the master gardener hat on. Do you care about that relationship for plants in how you plant things?
>> Mike North: Absolutely. But I think it goes beyond the basics here. I would love for that to be eventually part of this app, but for now, let's, like, let's focus on plant spacing as the core problem.
[00:13:23]
Plant spacing and how that is dealt with in the layout of plants in a bed of some kind. We can also assume the beds are rectangular for now, you know, and we'll see where this takes us. So I think this is a good starting point. We'll revisit this if, as we're implementing, we discover that there are things that we're missing.
Learn Straight from the Experts Who Shape the Modern Web
- In-depth Courses
- Industry Leading Experts
- Learning Paths
- Live Interactive Workshops