Delimited Context and Modules/Packages

Asked

Viewed 372 times

3

According to Domain Driven Design:

  • Pactoes must tell a story, are part of the ubiquitous language, organize related concepts;
  • The bounded context is the delimitation where the terms of omnipresent language have meaning;

Doubts:

  • The delimited context should be implemented as a package/namespace?
  • If the delimited context is a package/namespace, the packages that tell the history of the software must be within the delimited context?

how the package/namespace should be declared?

Nome_do_contexto_delimitado \ Nome_do_pacote

or

Nome_do_pacote \ Nome_do_contexto_delimitado

1 answer

2

Several Packages ("packages") can compose a single bounded context ("bounded context"), there is not necessarily a relation of 1 to 1.

A structure named after package that works well is:

contexto.assunto

Where the name of bounded context is the root or is close to the root of package (the root can also be something like with company name., hence the package name structure would be with.nomeempresa.context.subject matter)

"Subject" here is an area of interest within that context.

Examples of Packages and class names:

Bounded context Sales:

marketing.cliente.Cliente
marketing.cliente.Categoria
marketing.produto.Produto
marketing.produto.Categoria

Bounded context Logistics:

logistica.cliente.Cliente
logistica.produto.Produto

The subject may have subdivisions. For example:

marketing.produto.review.Review
marketing.produto.review.Consumidor
marketing.produto.review.Editor

Layer identification in package name

There may also be at the root or near the root of the name package the indication of the logical layer of that code, thus:

business.contexto.assunto
application.contexto.assunto

This helps maintain respect in the relationships between the layers (a code of business should never reference a code of application).

There are those who do this separation using folders or directories in the project. Informing the layer in the package name, however, allows identifying, analyzing only the source code, that some reference is disregarding the relationship between the layers. For example (Java):

package business.marketing;

import application.marketing.produto.*;

public class Cliente {...

In the above code, the reference that disrespects the relations is evident (and can be detected with a parsed code) in a way that would not be if the layer was not identified in the name of the package.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.