8

I've started learning the principles of DDD and I'm currently trying to get a grasp of the concept of a bounded context. In particular, how do you decide just how big (or small) it has to be? Yeah, I know, as small as possible and as big as necessary (according to Vaughn Vernon).

Let's say I were to model a blog. I could then go and say there are 3 bounded contexts involved: 1) Front Page (featuring the most recent articles, no comments shown) 2) Discussion (a single article including comments) 3) Article Composer (where I compose an article).

However, this doesn't feel right (the ubiquitous language is the same for all of them), it seems as if I'm coming from a front end point of view and am still thinking in terms of view models or something.

Could anyone please point me in the right direction?

Thorsten Westheider
  • 10,572
  • 14
  • 55
  • 97
  • 1
    I am not an expert of the topic, but I think you are right. Words like article and comments have always the same meanings, so it is a single bounded context, which is not a complicated one, all it does is simple CRUD. – inf3rno May 15 '15 at 10:55
  • 3
    It might not be worth it in this case, but BCs will emerge from behavior and concepts. For instance, your blog may have a management context allowing super admins to ban accounts and perform other administrative tasks. These aren't really part of the core domain of a blog and may justify a new BC. – plalx May 15 '15 at 13:04
  • @plalx Good point, immediately reminds me of the example in Vernon's book. – Thorsten Westheider May 15 '15 at 13:52

3 Answers3

4

A blog is not a good example for use of multiple bounded context. It's not really a "big enough" software example to warrant their definitions. DDD & BC's are really aimed at big/complex enterprising software systems.

Like you say, the aggregates always have the same meaning in your 3 examples.

I gave this example of Bounded Context in a previous answer, which I hope explains BC's and when to use them: Bounded Contexts and Aggregate Roots

Community
  • 1
  • 1
David Masters
  • 8,069
  • 2
  • 44
  • 75
  • 1
    Just getting my feet wet and as I'm in the process of building web site I thought why not apply DDD here to experiment with. I'm perfectly aware of this being some sort of overkill but I don't mind if by doing so I can get some experience with DDD. – Thorsten Westheider May 15 '15 at 14:04
2

Try to look at your whole domain from different perspectives, as an editor of article, you probably will use sentences like creating a draft of an article, publishing an article, as an article a reader you will in example read article and comment on it. Alongside building your domain language you will identify entities and their behaviour, some of them will appear only in one perspective, some will appear in both, but you will distinct them by their behaviour. Your domain language shows you the boundries of each perspective, that you implement as a bounded contexts.

pwc
  • 446
  • 3
  • 10
  • Yes, that was the idea. A comment doesn't make any sense while composing an article, and adding pictures in the composer is similar to that, as it doesn't make any sense on the front page. – Thorsten Westheider May 15 '15 at 13:56
  • I actually came up with these actions for the Composition BC: UpdateTitle, UpdateContent, Publish and Retract. In contrast I got AddComment for the Discussions BC. – Thorsten Westheider May 16 '15 at 08:59
2

The best example I read by subdomains so far is the following.

Just examine the actual company! Each department taking part in the business process can have its own subdomain. In an ideal world each subdomain has its own bounded context in your implementation. You should ask yourself whether the company needs a new department to do this? Is it really that big?

The BC must be big enough to describe a department of a company. A typical example is a webshop, where you have a shopping core domain and invoicing, delivery and storage subdomains. Having multi-tenancy and so multiple aspects - as a previous answer described - is not enough. A blog with an author and a few readers does not require multiple departments, so you can solve this with a single bounded context. You can have multiple modules in your bounded context if you think you have medium size structures in your bounded context.

inf3rno
  • 24,976
  • 11
  • 115
  • 197