Return HTML from bounded context

137 Views Asked by At

I've recently read a book about Domain Driven Design. But, I surprised when I read that sending back the HTML from bounded context to the presentation layer is one of the two approaches to return data from bounded context(another is via various data types like JSON and XML, ... as everyone uses it)!

This is the exact content of the book:

HTML APIs versus Data APIs

By constructing web pages with snippets of HTML that are returned from each bounded context, you give bounded contexts control of the appearance and behavior of specific regions of a page.

enter image description here

Now, I have two question about this:

  1. Is it really a good way to return HTML?
  2. Where HTML should be generated? In the application services as the last layer of bounded context or other layers or what?

reference: PATTERNS, PRINCIPLES, AND PRACTICES OF DOMAIN-DRIVEN DESIGN By Scott Millet & Nick Tune, published by Wrox

1

There are 1 best solutions below

0
On

I think the book is talking about composed UIs there. The html returned by each BC means the UI of the BC. The whole UI is a composition of all UIs. So each BC has its own UI.

Another approach would be to have just one UI. The BCs would have no UI, just application layer. The UI would call the application layer of the BC it needs, usually the glue between the UI and the BCs APIs would be a REST API gateway.