What are the most discussed Domain-Driven Design patterns?

Patterns in Part II are far more popular than other parts of the book. Three of these patterns (Entity, Service, and Repository) appear in more than 1,000 questions in both Stack Overflow and YG. Aggregates are also popular in both (1,041 questions in SO and 936 in YG). Entities, in particular, are the most popular one, appearing in 1,841 questions (45% of all questions) and 2,539 answers (32% of all answers) in SO, and in 1,351 questions (27%) and 3,934 (20%) in YG. No other part of the book contains such popular patterns. On the other hand, Part IV is the least popular one, as most patterns contains zero or less than 10 questions. Bounded Context is an exception in both datasets, appearing in 231 questions and in 451 answers in SO, and in 196 initial e-mails and 621 answers in YG.

There exist questions that do not focus on any pattern. Although, as expected, most questions focus on the patterns defined in the book, some of them do not. In SO, 18% of them do not mention any of them. This number is higher in the YG: 41%.

Number of questions and answers mentioning DDD patterns. T=Total of questions/answers, C=Questions/answers with source code, L=Questions/Answers with links.

Number of e-mails and answers mentioning DDD patterns in Yahoo! Groups. T=Total of questions/answers, C=Questions/answers with source code, L=Questions/Answers with links.

What kind of questions do developers ask?

We counted the number of "what"s, "how"s and "why"s that appeared in the title of all posts. Questions in SO seemed to follow this convention better than posts in YG.

"How" is the most popular type of question. In SO, we observed 1,064 how questions, 222 what questions, and 50 why questions. In YG, we counted 329 how questions, 110 what questions, and 15 why questions.

Entity is by far the one with more "how" questions. Entity received 301 how questions in SO. It is then followed by Repositories (199), Aggregates (187) and Services (185). In other parts of the book, Bounded Context (34) is the most popular one, although far from the aforementioned ones.

Types of questions (what, why, how) in SO and YG

How often does a discussion become technical (i.e. contains source code)?

The number of questions and answers with implementation details is

significant. A significant number of questions and answers contain pieces of source code. Patterns in Part II are the ones with more source code. While this is related to the fact that Part II is the most popular one in SO, some patterns

contain a high frequency of implementation details in their questions and answers. The Specification pattern, as an example, contains source code in 65% of its questions and in 51% of its answers. Similar numbers happen in many other patterns.

Questions and answers in SO are more likely to have source code

than e-mails in YG. In SO, we observe 1,985 and 2,091 questions with and without source code, respectively. In YG, these numbers go down to 546 and 4,545. Therefore, a question is SO is 8.76 times (95% confidence interval: 7.8714 — 9.7683, Chi-Square=<.0001) more likely to contain a source code than an initial e-mail in YG. We observe a similar likelihood in answers: While

SO contains 2,965 and 4,834 answers with and without source code, YG contains 1,344 and 18,170. This means that an answer in SO is 8.29 times (95% confidence interval: 7.7175 — 8.9099, Chi-Square=<.0001)more likely to contain a source code than an answer in YG.

What are the most common references in discussions?

It is common to find links in questions and answers. Interestingly, the presence of links is almost as frequent as source code. In some patterns, the number of links are even higher: Bounded Context contains links in 164 SO answers (while 113 with source code), Context Map contains links in 13 answers (and only 3 with source code), and Ubiquitous Language (109 against 106). We observe similar patterns also in YG dataset. Interestingly, this happens only in answers; the number of links is never higher than the number of source code in questions.

Developers refer to a total of 1,770 different links. SO users cited a total of 956 different links, while YG cited a total of 997. There is an intersection of 183 links between both datasets.

StackOverflow and Martin Fowler’s blog are the most popular references. In SO, users often refer to other SO links. In YG, Martin Fowler’s wiki is the most often cited reference. Fowler’s wiki is also popular in SO, with a total of 432 citations. Other common references for both datasets is domaindrivendesign.org (the DDD official website), Wikipedia, and Udi Dahan’s personal blog.

Questions and answers in SO are more likely to have links than e-mails in YG. There are 744 and 3,332 questions with and without links in SO. Same numbers for YG are 721 and 4,370. Thus, questions in SO are 1.35 times (95% confidence interval: 1.21 — 1.51, Chi-Square=<.0001) more likely to contain a link than YG. In addition, SO has 2,679 and 5,120 answers with and without links. YG numbers are 2,321 and 17,193. Therefore, answers in SO are 3.87 times (95% confidence interval: 3.63 — 4.13) more likely to contain a link than an answer in YG.

Common references in DDD posts.

Are topics correlated to each other?

We applied the Apriori algorithm, the traditional approach to mine association rules. After deciding minimum support and confidence, the algorithm computes the set of all rules that are above these thresholds.

The algorithm was able to generate 2,432 association rules. In the following, we list the top 10 rules ordered by their lift.

Top 10 association rules for both Stack Overflow and Yahoo! Groups.

Part II patterns are strongly connected among themselves. The Entity pattern frequently happens with Value Object, Repository, and Aggregate. In addition, Factory is associated with Repository. On the other hand, some of them tend not appear together: Value objects, Aggregates, and Entities are not often found together with Services.

Patterns from other parts of the book are disconnected from Part II. Patterns such as Ubiquitous Language, Bounded Context, and Layered Architecture does not happen together with patterns in Part II. In fact, we observe many rules A => !B, with A being such patterns, suggesting that they tend to happen alone.