Archives for March, 2018

Bounded contexts and subdomains

published on March 20, 2018.

Back in October last year I wrote that I thought I understood bounded contexts, what they are and why we need them. Ever since realizing that a bounded context is a boundary of how a business sees a specific subject within a section of that business, learning anything and everything DDD became a lot easier.

I see bounded contexts as a big building block without which learning other parts of DDD is pretty much pointless. OK, pointless might be too harsh a word, but to be able to use entities, value objects, domain events, aggregates to their full potential, a good understanding of bounded contexts is needed.

Of course I didn’t stop learning about DDD since writing that post 5 months ago. If anything, I did my best to learn even more by reading books and articles, watching recorded conference talks, and thinking about this subject. A lot.

Uh, phrasing

In my previous post I had this image attached that I used to help explain the difference between a Book in two different bounded contexts. Recently I realized that that image has mistake in it. On that image I used the terms “Publisher” and “Seller” to distinguish the two bounded contexts. A better name for those would probably be “Publishing” and “Selling”.

It is important to get the naming right as it affects the understanding a great deal. It might not be an outright mistake, but a bounded context is probably better off not being named after a thing. Publisher, seller, warehouse, these are the things we model inside our bounded contexts. A bounded context should name in what context do these models apply: publishing, selling, warehousing. Properly naming a bounded context will also help to identify should a model of something be an aggregate (root), an entity, or a value object.

There are probably other things I got wrong in that post, but so far I see this naming issue as the biggest one.

What about subdomains?

One thing I didn’t know and understand when I was writing the previous post was the importance of (sub)domains in connection with bounded contexts. I’m still not 100% sure I do. A business operates within a domain and that’s what we’re trying to design and model with DDD. It has one core domain which represents the reason why the business exists in the first place and at least one more subdomain that supports that core domain. The core domain is the main problem a business is trying to solve and the subdomains are all the other problems that come along with trying to solve the core domain problem.

Vaughn Vernon in his “Implementing Domain-Driven Design” book states (I’m paraphrasing here a bit) that “the subdomains live in the problem space and the bounded contexts in the solution space”. It took me a while to really understand this and what the implications of it are.

When writing software that will support the business and help solving the problems coming from the core domain and supporting subdomains we create models. These models will be “fine tuned” so that they provide the most optimal solution for the problem. But to provide these solutions, we also need to say what is the context of these models in which they help solve the problem.

Imagine a software that is being developed to support a dentist. A dentist has two problems: fixing patients’ teeth and making appointments for the patients. Fixing teeth is the core domain and making appointments is a supporting subdomain. In the core domain the medical staff cares about a patient’s dental history, can they handle general anesthesia or not, what their current problem is, etc. In the subdomain the staff (not necessarily medical staff) cares about a patient’s contact information, a date and a time that best suits both the doctor and the patient, the type of dental work needed, etc. Both domains need a model of a patient, but that model will depend on the bounded context we put in place to ensure the correct information and features are available when solving the problems of each domain.

Subdomains and bounded contexts go hand in hand and I think one can’t be understood without the other. The optimal solution would be to have one bounded context in one subdomain. The world is not a perfect place, software even less so, so it might happen that one bounded context spans multiple subdomains, or that one subdomain has multiple bounded contexts.

Problems and solutions

A key element to DDD is that our understanding of the domain will constantly change, improve, as we learn more about it. That’s one of the reasons why we need to be ready to change or throw away models we came up with. This ever-evolving state means that the subdomains and the bounded contexts can and will change, too.

A bounded context can grow or shrink, split in two, be combined in one, regardless of the subdomain(s) it is in. Taking a different approach in solving a problem doesn’t mean that the problem itself has changed.

On the other hand if the problem changes, the solution should change too. If during development we realize that the core domain can be further split into a smaller, more focused core domain and a new subdomain then the solution to those problems should change. Most likely the models we developed don’t fit the problems any more and the boundaries around our contexts have moved.

This post has evolved, too

Initially this wasn’t the post I wanted to write. I did start writing about bounded contexts, but then I realized I can’t talk about them without talking about subdomains. Both the title and the contents changed at least 3 times. More topics to cover in the future I guess.

Happy hackin’!

A weekly to-do

published on March 08, 2018.

About a year ago I listened to a ThatPodcast episode where Dave and Beau talked about bullet journalling. I found the idea of it appealing, but over the next few months I just couldn’t find a bullet journal in any of the (book)stores I went to. As time passed so did my interest in this. After all, I was getting along without such a system just fine. My life isn’t that crazy busy, 7-8 hours of sleep, 7-10 hours of work work, and the rest is up for grabs — hanging out with my wife Senka (her name translates to Shadow, how cool is that?), reading, writing, cooking, open source, whatever.

For work work I’m organized, a Google calendar, couple of Trello boards, and that’s pretty much it. No issues there. My free time though… I realized that can get a bit messy from time to time. Especially when Senka works 2nd shift, then it’s just me and our cat from 5pm until 10pm that entire week. Lots of time there and I soon noticed that when I want to do lots of things all at once, nothing gets really done.

In September or October last year I read somewhere, can’t remember was it a book or an article, something about organizing to-do tasks in weekly chunks. Now that was an interesting idea especially since Senka changes shifts weekly which means that with a weekly plan/schedule I could plan things around her shifts. Quality time with her comes first. Then I remembered the bullet journalling thing and started thinking about a way to combine these two in one system.

For the past 4 months I’ve been using this weekly to-do approach where every Monday morning I write down what I need and want to do during the week. Going to the bank to pay the bills, sending out an email to a friend to catch up, writing a blog post, having a DnD session, look into a open source issue, organize an upcoming trip, finish reading a book I was putting off for way too long. If something pops up during the week I add it to the list. If something gets “obsolete”, cross it off. Every item gets a dot in front of it, just like with bullet journaling. Once it’s done I turn that dot into a plus and write down the date.

Next Monday I tally the previous week by writing down the to-do vs. done ratio. For any items left over from the previous week I turn the dot into a greater than sign and move it over to the new week and add new items to the list. If a task list “overflows” for 3 weeks in a row I strike it through and move it a Trello board full of stuff that probably won’t ever happen. I mean if I couldn’t find the time to do something in 3 weeks I guess it’s just not that important after all.

4 months of this and it’s working really great for me. There are weeks when I end up having almost 20 items on the list and there are weeks when I have 5 or 6. Weeks when I finish everything are rare, happened maybe 3 times so far. I’m fine with that as the things that really need to be done or I really want them done get done. The rest takes care of itself.

The past 3 weeks I’ve been experimenting with adding a weekly focus note which should act as a guiding system if the items on the list are too scattered, so just to keep myself in check that I’m actually working on the things that will worth the most over time. Another improvement I’m thinking about is somehow to measure and note the biggest accomplishment of the previous week so that maybe I could also see some general progress over the months.

Happy hackin’!

Tags: about, to-do, bullet journal.
Categories: Blablabla.
Robert Basic

Robert Basic

Software engineer, consultant, open source contributor.

Let's work together!

If you require outsourcing or consulting help on your projects, I'm available!

Robert Basic © 2008 — 2018
Get the feed