Context Delimited and Modules / Packages

3

According to Domain Driven Design:

  • Covenants should tell a story, be part of the ubiquitous language, organize related concepts;
  • The delimited context is where the terms of the ubiquitous language have meaning;

Questions:

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

How should the package / namespace be declared?

Delimited ContextName \ PackageName

or

PackageName \ DelimitedContextName

    
asked by anonymous 24.06.2015 / 14:41

1 answer

2

Many packages can compose a single bounded context ("bounded context"), there is not necessarily a 1 to 1 relationship.

>

A package name structure that works well is:

contexto.assunto

Where the bounded context name is the root or is close to the package root (the root can also be something like withcompanyname >, hence the structure of the package name would be withcompanyname.context.name )

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

Examples of package names and classes:

Bounded context Sales:

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

Bounded context Logistics:

logistica.cliente.Cliente
logistica.produto.Produto

Subject can have subdivisions. For example:

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

Identifying the layer in the package name

There may also be in the root or near the root of the package name of the logical layer of that code, like this:

business.contexto.assunto
application.contexto.assunto

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

Some people do this separation using folders or directories in the project. Informing the layer in the name of the package itself, however, allows identifying, by analyzing only the source code, that some reference is disrespecting 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 code parser) in a way that would not be if the layer was not identified in the package name. / p>     

24.06.2015 / 18:04